From bce1dfc6b75857e46cd36a44467454a7b02cb7ed Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Fri, 21 May 2021 21:22:41 +0200 Subject: Fixed up error reporting in BasicFile, now uses ThrowSystemException() to correctly report the HRESULT error code which would previously always be zero --- zenstore/basicfile.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'zenstore/basicfile.cpp') diff --git a/zenstore/basicfile.cpp b/zenstore/basicfile.cpp index 05af4f792..0164a45ee 100644 --- a/zenstore/basicfile.cpp +++ b/zenstore/basicfile.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -19,7 +20,7 @@ BasicFile::Open(std::filesystem::path FileName, bool isCreate) if (FAILED(hRes)) { - throw std::system_error(GetLastError(), std::system_category(), "Failed to open bucket sobs file '{}'"_format(FileName)); + ThrowSystemException(hRes, "Failed to open bucket sobs file '{}'"_format(FileName)); } } @@ -35,9 +36,7 @@ BasicFile::Read(void* Data, uint64_t Size, uint64_t Offset) if (FAILED(hRes)) { - throw std::system_error(GetLastError(), - std::system_category(), - "Failed to read from file '{}'"_format(zen::PathFromHandle(m_File))); + ThrowSystemException(hRes, "Failed to read from file '{}'"_format(zen::PathFromHandle(m_File))); } } @@ -63,7 +62,7 @@ BasicFile::Write(const void* Data, uint64_t Size, uint64_t Offset) if (FAILED(hRes)) { - throw std::system_error(GetLastError(), std::system_category(), "Failed to write to file '{}'"_format(zen::PathFromHandle(m_File))); + ThrowSystemException(hRes, "Failed to write to file '{}'"_format(zen::PathFromHandle(m_File))); } } @@ -82,4 +81,4 @@ BasicFile::FileSize() return uint64_t(Sz); } -} +} // namespace zen -- cgit v1.2.3