diff options
| author | Stefan Boberg <[email protected]> | 2021-05-21 21:17:12 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-05-21 21:17:12 +0200 |
| commit | 9f62b35a7380db253cce3310fa5208b8c8e20ef5 (patch) | |
| tree | ea6bdb2a876649c2eb5e1142d9c1a2a2d1c96ca8 /zencore/include | |
| parent | Renamed CasBlobFile -> BasicFile (diff) | |
| download | zen-9f62b35a7380db253cce3310fa5208b8c8e20ef5.tar.xz zen-9f62b35a7380db253cce3310fa5208b8c8e20ef5.zip | |
Cleaned up exception handling
We now use std::system_error where possible to report Win32 system errors. We still have WindowsException for general HRESULT based errors but we should phase it out where possible
Diffstat (limited to 'zencore/include')
| -rw-r--r-- | zencore/include/zencore/except.h | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/zencore/include/zencore/except.h b/zencore/include/zencore/except.h index 8f5f50e86..782dbeed0 100644 --- a/zencore/include/zencore/except.h +++ b/zencore/include/zencore/except.h @@ -11,18 +11,12 @@ namespace zen { class WindowsException : public std::exception { public: - WindowsException(const char* Message) + WindowsException(std::string_view Message) { m_hResult = HRESULT_FROM_WIN32(GetLastError()); m_Message = Message; } - WindowsException(HRESULT hRes, const char* Message) - { - m_hResult = hRes; - m_Message = Message; - } - WindowsException(HRESULT hRes, std::string_view Message) { m_hResult = hRes; @@ -49,18 +43,14 @@ private: HRESULT m_hResult; }; -ZENCORE_API void ThrowSystemException(HRESULT hRes, const char* Message); +ZENCORE_API void ThrowSystemException(HRESULT hRes, std::string_view Message); + inline void ThrowSystemException(const char* Message) { throw WindowsException(Message); } -inline void -ThrowIfFailed(HRESULT hRes, const char* Message) -{ - if (FAILED(hRes)) - ThrowSystemException(hRes, Message); -} +ZENCORE_API void ThrowLastError(std::string_view Message); } // namespace zen |