diff options
| author | Stefan Boberg <[email protected]> | 2021-05-21 21:22:41 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-05-21 21:22:41 +0200 |
| commit | bce1dfc6b75857e46cd36a44467454a7b02cb7ed (patch) | |
| tree | f79649a674cba537666347299cd07656d826d49a /zenstore/basicfile.cpp | |
| parent | Cleaned up exception handling (diff) | |
| download | zen-bce1dfc6b75857e46cd36a44467454a7b02cb7ed.tar.xz zen-bce1dfc6b75857e46cd36a44467454a7b02cb7ed.zip | |
Fixed up error reporting in BasicFile, now uses ThrowSystemException() to correctly report the HRESULT error code which would previously always be zero
Diffstat (limited to 'zenstore/basicfile.cpp')
| -rw-r--r-- | zenstore/basicfile.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
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 <zencore/filesystem.h> #include <zencore/fmtutils.h> +#include <zencore/except.h> #include <fmt/format.h> #include <gsl/gsl-lite.hpp> @@ -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 |