aboutsummaryrefslogtreecommitdiff
path: root/src/zencore/iobuffer.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2023-09-12 08:03:46 -0400
committerGitHub <[email protected]>2023-09-12 14:03:46 +0200
commitf463686b9621b8c744e2dcb0d018ad507716d499 (patch)
tree7cf50625dbfe3b731131b779c6286ae9ca6423d7 /src/zencore/iobuffer.cpp
parentgracefully handle errors when writing cache log (#391) (diff)
downloadzen-f463686b9621b8c744e2dcb0d018ad507716d499.tar.xz
zen-f463686b9621b8c744e2dcb0d018ad507716d499.zip
Make sure error logging or destructors don't throw exception when trying to get file name from handle (#393)
- Bugfix: Make sure error logging or destructors don't throw exception when trying to get file name from handle
Diffstat (limited to 'src/zencore/iobuffer.cpp')
-rw-r--r--src/zencore/iobuffer.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/zencore/iobuffer.cpp b/src/zencore/iobuffer.cpp
index efec06f7f..73600a09e 100644
--- a/src/zencore/iobuffer.cpp
+++ b/src/zencore/iobuffer.cpp
@@ -332,17 +332,18 @@ IoBufferExtendedCore::Materialize() const
#endif // ZEN_PLATFORM_WINDOWS
if (Error || (BytesRead != m_DataBytes))
{
+ std::error_code DummyEc;
ZEN_ERROR("ReadFile/pread failed (offset {:#x}, size {:#x}) file: '{}' (size {:#x}), {}",
m_FileOffset,
m_DataBytes,
- zen::PathFromHandle(m_FileHandle),
+ zen::PathFromHandle(m_FileHandle, DummyEc),
zen::FileSizeFromHandle(m_FileHandle),
GetSystemErrorAsString(Error));
throw std::system_error(std::error_code(Error, std::system_category()),
fmt::format("ReadFile/pread failed (offset {:#x}, size {:#x}) file: '{}' (size {:#x})",
m_FileOffset,
m_DataBytes,
- PathFromHandle(m_FileHandle),
+ PathFromHandle(m_FileHandle, DummyEc),
FileSizeFromHandle(m_FileHandle)));
}
@@ -368,10 +369,11 @@ IoBufferExtendedCore::Materialize() const
if (NewMmapHandle == nullptr)
{
- int32_t Error = zen::GetLastError();
- ZEN_ERROR("CreateFileMapping failed on file '{}', {}", zen::PathFromHandle(m_FileHandle), GetSystemErrorAsString(Error));
+ int32_t Error = zen::GetLastError();
+ std::error_code DummyEc;
+ ZEN_ERROR("CreateFileMapping failed on file '{}', {}", zen::PathFromHandle(m_FileHandle, DummyEc), GetSystemErrorAsString(Error));
throw std::system_error(std::error_code(Error, std::system_category()),
- fmt::format("CreateFileMapping failed on file '{}'", zen::PathFromHandle(m_FileHandle)));
+ fmt::format("CreateFileMapping failed on file '{}'", zen::PathFromHandle(m_FileHandle, DummyEc)));
}
NewFlags |= kOwnsMmap;
@@ -401,17 +403,18 @@ IoBufferExtendedCore::Materialize() const
CloseHandle(NewMmapHandle);
#endif // ZEN_PLATFORM_WINDOWS
+ std::error_code DummyEc;
ZEN_ERROR("MapViewOfFile/mmap failed (offset {:#x}, size {:#x}) file: '{}' (size {:#x}), {}",
MapOffset,
MapSize,
- zen::PathFromHandle(m_FileHandle),
+ zen::PathFromHandle(m_FileHandle, DummyEc),
zen::FileSizeFromHandle(m_FileHandle),
GetSystemErrorAsString(Error));
throw std::system_error(std::error_code(Error, std::system_category()),
fmt::format("MapViewOfFile failed (offset {:#x}, size {:#x}) file: '{}' (size {:#x})",
MapOffset,
MapSize,
- zen::PathFromHandle(m_FileHandle),
+ zen::PathFromHandle(m_FileHandle, DummyEc),
zen::FileSizeFromHandle(m_FileHandle)));
}