aboutsummaryrefslogtreecommitdiff
path: root/zenstore/basicfile.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-05-21 21:22:41 +0200
committerStefan Boberg <[email protected]>2021-05-21 21:22:41 +0200
commitbce1dfc6b75857e46cd36a44467454a7b02cb7ed (patch)
treef79649a674cba537666347299cd07656d826d49a /zenstore/basicfile.cpp
parentCleaned up exception handling (diff)
downloadzen-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.cpp11
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