diff options
| author | Martin Ridgers <[email protected]> | 2021-12-02 08:54:52 +0100 |
|---|---|---|
| committer | Martin Ridgers <[email protected]> | 2021-12-02 11:36:19 +0100 |
| commit | 47d2797f80dde7593517d013b83640ad037eac32 (patch) | |
| tree | 04cabcd49f5dbe54aa107b9f334a125ea4d2a60c | |
| parent | Use zen::Memory::Alloc/Free instead of unportable _aligned_* (diff) | |
| download | zen-47d2797f80dde7593517d013b83640ad037eac32.tar.xz zen-47d2797f80dde7593517d013b83640ad037eac32.zip | |
Use zen::ThrowLastError() in place of throwing system_error directly
| -rw-r--r-- | zen/internalfile.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/zen/internalfile.cpp b/zen/internalfile.cpp index 1eab04486..fc473b241 100644 --- a/zen/internalfile.cpp +++ b/zen/internalfile.cpp @@ -2,6 +2,7 @@ #include "internalfile.h" +#include <zencore/except.h> #include <zencore/filesystem.h> #include <zencore/fmtutils.h> #include <zencore/logging.h> @@ -152,7 +153,7 @@ InternalFile::OpenWrite(std::filesystem::path FileName, bool IsCreate) if (FAILED(hRes)) { using namespace fmt::literals; - throw std::system_error(GetLastError(), std::system_category(), "Failed to open file for writing: '{}'"_format(FileName)); + zen::ThrowLastError("Failed to open file for writing: '{}'"_format(FileName)); } } @@ -166,7 +167,7 @@ InternalFile::OpenRead(std::filesystem::path FileName) if (FAILED(hRes)) { using namespace fmt::literals; - throw std::system_error(GetLastError(), std::system_category(), "Failed to open file for reading: '{}'"_format(FileName)); + zen::ThrowLastError("Failed to open file for reading: '{}'"_format(FileName)); } } @@ -201,9 +202,7 @@ InternalFile::Read(void* Data, uint64_t Size, uint64_t Offset) if (FAILED(hRes)) { using namespace fmt::literals; - throw std::system_error(GetLastError(), - std::system_category(), - "Failed to read from file '{}'"_format(zen::PathFromHandle(m_File))); + zen::ThrowLastError("Failed to read from file '{}'"_format(""));//zen::PathFromHandle(m_File))); } } @@ -220,7 +219,7 @@ InternalFile::Write(const void* Data, uint64_t Size, uint64_t Offset) if (FAILED(hRes)) { using namespace fmt::literals; - throw std::system_error(GetLastError(), std::system_category(), "Failed to write to file '{}'"_format(zen::PathFromHandle(m_File))); + zen::ThrowLastError("Failed to write to file '{}'"_format(""));//zen::PathFromHandle(m_File))); } } |