diff options
Diffstat (limited to 'dxcommon/include')
| -rw-r--r-- | dxcommon/include/dxcommon.h | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/dxcommon/include/dxcommon.h b/dxcommon/include/dxcommon.h index 0270629..e04f8e9 100644 --- a/dxcommon/include/dxcommon.h +++ b/dxcommon/include/dxcommon.h | |||
| @@ -10,9 +10,10 @@ namespace dx { | |||
| 10 | 10 | ||
| 11 | using Microsoft::WRL::ComPtr; | 11 | using Microsoft::WRL::ComPtr; |
| 12 | 12 | ||
| 13 | class exception : public std::exception { | 13 | class exception : public std::exception |
| 14 | { | ||
| 14 | public: | 15 | public: |
| 15 | exception() noexcept {} | 16 | exception() noexcept = default; |
| 16 | 17 | ||
| 17 | exception(HRESULT result, const char* file, int line) noexcept | 18 | exception(HRESULT result, const char* file, int line) noexcept |
| 18 | { | 19 | { |
| @@ -25,7 +26,7 @@ public: | |||
| 25 | sprintf_s(m_error, sizeof(m_error), "%s:%d %s", file, line, error); | 26 | sprintf_s(m_error, sizeof(m_error), "%s:%d %s", file, line, error); |
| 26 | } | 27 | } |
| 27 | 28 | ||
| 28 | const char* what() const noexcept | 29 | [[nodiscard]] const char* what() const noexcept final |
| 29 | { | 30 | { |
| 30 | return m_error; | 31 | return m_error; |
| 31 | } | 32 | } |
| @@ -36,8 +37,10 @@ private: | |||
| 36 | 37 | ||
| 37 | #define THROW(error) throw exception(error, __FILE__, __LINE__) | 38 | #define THROW(error) throw exception(error, __FILE__, __LINE__) |
| 38 | 39 | ||
| 39 | #define ThrowIfFailed(result) {\ | 40 | #define ThrowIfFailed(result) \ |
| 40 | if (result != S_OK) {\ | 41 | {\ |
| 42 | if (result != S_OK) \ | ||
| 43 | {\ | ||
| 41 | THROW(result);\ | 44 | THROW(result);\ |
| 42 | }\ | 45 | }\ |
| 43 | } | 46 | } |
