Skip to content

Commit

Permalink
Merge pull request duckdb#11723 from Mytherin/bettermkdirerror
Browse files Browse the repository at this point in the history
Improve mkdir error reporting
  • Loading branch information
Mytherin authored Apr 19, 2024
2 parents e00d442 + 866a328 commit 6bd83ee
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/common/local_file_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,8 @@ void LocalFileSystem::CreateDirectory(const string &directory, optional_ptr<File
if (stat(directory.c_str(), &st) != 0) {
/* Directory does not exist. EEXIST for race condition */
if (mkdir(directory.c_str(), 0755) != 0 && errno != EEXIST) {
throw IOException("Failed to create directory \"%s\"!", {{"errno", std::to_string(errno)}}, directory);
throw IOException("Failed to create directory \"%s\": %s", {{"errno", std::to_string(errno)}}, directory,
strerror(errno));
}
} else if (!S_ISDIR(st.st_mode)) {
throw IOException("Failed to create directory \"%s\": path exists but is not a directory!",
Expand Down Expand Up @@ -989,7 +990,8 @@ void LocalFileSystem::CreateDirectory(const string &directory, optional_ptr<File
}
auto unicode_path = WindowsUtil::UTF8ToUnicode(directory.c_str());
if (directory.empty() || !CreateDirectoryW(unicode_path.c_str(), NULL) || !DirectoryExists(directory)) {
throw IOException("Could not create directory: \'%s\'", directory.c_str());
auto error = LocalFileSystem::GetLastErrorAsString();
throw IOException("Failed to create directory \"%s\": %s", directory.c_str(), error);
}
}

Expand Down

0 comments on commit 6bd83ee

Please sign in to comment.