diff options
| author | Stefan Boberg <[email protected]> | 2021-05-25 09:54:09 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-05-25 09:54:09 +0200 |
| commit | 882e93e4786f9e67e0edf6c276b16bb40848bae9 (patch) | |
| tree | c5d4c45679c676c6aeb804c7601f43340b78ea0b /zencore/except.cpp | |
| parent | Updated structured cache description (diff) | |
| parent | Compile out all rocksdb code for a smaller binary (diff) | |
| download | zen-882e93e4786f9e67e0edf6c276b16bb40848bae9.tar.xz zen-882e93e4786f9e67e0edf6c276b16bb40848bae9.zip | |
Merged from origin/main
Diffstat (limited to 'zencore/except.cpp')
| -rw-r--r-- | zencore/except.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/zencore/except.cpp b/zencore/except.cpp index b02122f58..882f69f9a 100644 --- a/zencore/except.cpp +++ b/zencore/except.cpp @@ -1,17 +1,27 @@ // Copyright Epic Games, Inc. All Rights Reserved. #include <zencore/except.h> +#include <system_error> namespace zen { void -ThrowSystemException([[maybe_unused]] HRESULT hRes, [[maybe_unused]] const char* Message) +ThrowSystemException([[maybe_unused]] HRESULT hRes, [[maybe_unused]] std::string_view Message) { - // TODO - - int ErrValue = hRes; + if (HRESULT_FACILITY(hRes) == FACILITY_WIN32) + { + throw std::system_error(std::error_code(hRes & 0xffff, std::system_category()), std::string(Message)); + } + else + { + throw WindowsException(hRes, Message); + } +} - throw std::system_error(ErrValue, std::system_category(), Message); +void +ThrowLastError(std::string_view Message) +{ + throw std::system_error(std::error_code(::GetLastError(), std::system_category()), std::string(Message)); } } // namespace zen |