Skip to content

Commit d22abb7

Browse files
Improve error message when creating a temporary file fails
Add the temporary file path and the specific system error when `mkstemp` fails. PiperOrigin-RevId: 871317143
1 parent 4cc6fd2 commit d22abb7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tsl/platform/path.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ limitations under the License.
2020
#include <stdlib.h>
2121
#include <sys/stat.h>
2222
#include <sys/types.h>
23+
24+
#include <cstring>
2325
#if defined(PLATFORM_WINDOWS)
2426
#include <windows.h>
2527
#else
@@ -338,7 +340,8 @@ string GetTempFilename(const string& extension) {
338340
fd = mkstemp(&tmp_filepath[0]);
339341
}
340342
if (fd < 0) {
341-
LOG(FATAL) << "Failed to create temp file.";
343+
LOG(FATAL) << "Failed to create temp file " << tmp_filepath // Crash OK
344+
<< ", error: " << strerror(errno);
342345
} else {
343346
if (close(fd) < 0) {
344347
LOG(ERROR) << "close() failed: " << strerror(errno);

0 commit comments

Comments
 (0)