diff options
Diffstat (limited to 'zencore/except.cpp')
| -rw-r--r-- | zencore/except.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/zencore/except.cpp b/zencore/except.cpp index 9bd447308..834585522 100644 --- a/zencore/except.cpp +++ b/zencore/except.cpp @@ -2,10 +2,11 @@ #include <fmt/format.h> #include <zencore/except.h> -#include <system_error> namespace zen { +#if ZEN_PLATFORM_WINDOWS + void ThrowSystemException([[maybe_unused]] HRESULT hRes, [[maybe_unused]] std::string_view Message) { @@ -19,16 +20,18 @@ ThrowSystemException([[maybe_unused]] HRESULT hRes, [[maybe_unused]] std::string } } +#endif // ZEN_PLATFORM_WINDOWS + void ThrowLastError(std::string_view Message) { - throw std::system_error(std::error_code(::GetLastError(), std::system_category()), std::string(Message)); + throw std::system_error(std::error_code(zen::GetLastError(), std::system_category()), std::string(Message)); } std::string GetLastErrorAsString() { - return GetWindowsErrorAsString(::GetLastError()); + return GetWindowsErrorAsString(zen::GetLastError()); } std::string @@ -37,12 +40,14 @@ GetWindowsErrorAsString(uint32_t Win32ErrorCode) return std::error_code(Win32ErrorCode, std::system_category()).message(); } +#if __cpp_lib_source_location void ThrowLastError(std::string_view Message, const std::source_location& Location) { using namespace fmt::literals; - throw std::system_error(std::error_code(::GetLastError(), std::system_category()), + throw std::system_error(std::error_code(zen::GetLastError(), std::system_category()), "{}({}): {}"_format(Location.file_name(), Location.line(), Message)); } +#endif } // namespace zen |