aboutsummaryrefslogtreecommitdiff
path: root/zencore/except.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-09-17 19:04:26 +0200
committerStefan Boberg <[email protected]>2021-09-17 19:04:26 +0200
commit025999f216f0fe99d0eacd1f7a9c6276b834bcb8 (patch)
treeca19984e18371192fa2d80398178b1fdd448b52c /zencore/except.cpp
parentclang-format (diff)
downloadzen-025999f216f0fe99d0eacd1f7a9c6276b834bcb8.tar.xz
zen-025999f216f0fe99d0eacd1f7a9c6276b834bcb8.zip
Removed WindowsException from public headers
Diffstat (limited to 'zencore/except.cpp')
-rw-r--r--zencore/except.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/zencore/except.cpp b/zencore/except.cpp
index 9bf043f4a..c06a26edd 100644
--- a/zencore/except.cpp
+++ b/zencore/except.cpp
@@ -7,6 +7,41 @@ namespace zen {
#if ZEN_PLATFORM_WINDOWS
+class WindowsException : public std::exception
+{
+public:
+ WindowsException(std::string_view Message)
+ {
+ m_hResult = HRESULT_FROM_WIN32(GetLastError());
+ m_Message = Message;
+ }
+
+ WindowsException(HRESULT hRes, std::string_view Message)
+ {
+ m_hResult = hRes;
+ m_Message = Message;
+ }
+
+ WindowsException(HRESULT hRes, const char* Message, const char* Detail)
+ {
+ m_hResult = hRes;
+
+ ExtendableStringBuilder<128> msg;
+ msg.Append(Message);
+ msg.Append(" (detail: '");
+ msg.Append(Detail);
+ msg.Append("')");
+
+ m_Message = msg.c_str();
+ }
+
+ virtual const char* what() const override { return m_Message.c_str(); }
+
+private:
+ std::string m_Message;
+ HRESULT m_hResult;
+};
+
void
ThrowSystemException([[maybe_unused]] HRESULT hRes, [[maybe_unused]] std::string_view Message)
{