aboutsummaryrefslogtreecommitdiff
path: root/src/zencore/filesystem.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2023-12-11 06:37:15 -0500
committerGitHub <[email protected]>2023-12-11 12:37:15 +0100
commitb12bee3b78e1cfb5080309eca2af34f9b87a977b (patch)
treefd4afadb03d74cea661a46a888807b25327ab6e9 /src/zencore/filesystem.cpp
parentmem cache perf improvements (#592) (diff)
downloadzen-b12bee3b78e1cfb5080309eca2af34f9b87a977b.tar.xz
zen-b12bee3b78e1cfb5080309eca2af34f9b87a977b.zip
Make sure that PathFromHandle don't hide true error when throwing exceptions (#600)
* Make sure that PathFromHandle don't hide true error when throwing exceptions * changelog * return error info in PathFromHandle if path fails to resolve
Diffstat (limited to 'src/zencore/filesystem.cpp')
-rw-r--r--src/zencore/filesystem.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/zencore/filesystem.cpp b/src/zencore/filesystem.cpp
index e9b147be5..29ec14e0c 100644
--- a/src/zencore/filesystem.cpp
+++ b/src/zencore/filesystem.cpp
@@ -1288,12 +1288,12 @@ PathFromHandle(void* NativeHandle, std::error_code& Ec)
{
if (NativeHandle == nullptr)
{
- return std::filesystem::path();
+ return "<error handle 'nullptr'>";
}
#if ZEN_PLATFORM_WINDOWS
if (NativeHandle == INVALID_HANDLE_VALUE)
{
- return std::filesystem::path();
+ return "<error handle 'invalid handle'>";
}
auto GetFinalPathNameByHandleWRetry =
@@ -1330,7 +1330,7 @@ PathFromHandle(void* NativeHandle, std::error_code& Ec)
if (Error != ERROR_SUCCESS)
{
Ec = MakeErrorCodeFromLastError();
- return std::filesystem::path();
+ return fmt::format("<error handle '{}'>", Ec.message());
}
if (RequiredLengthIncludingNul < PathDataSize)
@@ -1347,7 +1347,7 @@ PathFromHandle(void* NativeHandle, std::error_code& Ec)
if (Error != ERROR_SUCCESS)
{
Ec = MakeErrorCodeFromLastError();
- return std::filesystem::path();
+ return fmt::format("<error handle '{}'>", Ec.message());
}
ZEN_UNUSED(FinalLength);
return FullPath;
@@ -1361,7 +1361,7 @@ PathFromHandle(void* NativeHandle, std::error_code& Ec)
if (BytesRead <= 0)
{
Ec = MakeErrorCodeFromLastError();
- return {};
+ return fmt::format("<error handle '{}'>", Ec.message());
}
Link[BytesRead] = '\0';
@@ -1372,7 +1372,7 @@ PathFromHandle(void* NativeHandle, std::error_code& Ec)
if (fcntl(Fd, F_GETPATH, Path) < 0)
{
Ec = MakeErrorCodeFromLastError();
- return {};
+ return fmt::format("<error handle '{}'>", Ec.message());
}
return Path;