aboutsummaryrefslogtreecommitdiff
path: root/zencore/include
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-05-21 21:17:12 +0200
committerStefan Boberg <[email protected]>2021-05-21 21:17:12 +0200
commit9f62b35a7380db253cce3310fa5208b8c8e20ef5 (patch)
treeea6bdb2a876649c2eb5e1142d9c1a2a2d1c96ca8 /zencore/include
parentRenamed CasBlobFile -> BasicFile (diff)
downloadzen-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.h18
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