diff options
author | crupest <crupest@outlook.com> | 2019-12-16 00:09:52 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-12-16 00:09:52 +0800 |
commit | 6ad6638adf64d958cdae44ce1df6a8a3787fed84 (patch) | |
tree | 030af9ca6e19bebc6250a8d278e46af7065fcd2f /include/cru/win/exception.hpp | |
parent | 221c62de313ad811ca2b3ae8ba43996c96c347bc (diff) | |
download | cru-6ad6638adf64d958cdae44ce1df6a8a3787fed84.tar.gz cru-6ad6638adf64d958cdae44ce1df6a8a3787fed84.tar.bz2 cru-6ad6638adf64d958cdae44ce1df6a8a3787fed84.zip |
...
Diffstat (limited to 'include/cru/win/exception.hpp')
-rw-r--r-- | include/cru/win/exception.hpp | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/include/cru/win/exception.hpp b/include/cru/win/exception.hpp index 9e038960..95eb4079 100644 --- a/include/cru/win/exception.hpp +++ b/include/cru/win/exception.hpp @@ -10,12 +10,11 @@ namespace cru::platform::win { class HResultError : public platform::PlatformException { public: explicit HResultError(HRESULT h_result); - explicit HResultError(HRESULT h_result, - const std::string_view& additional_message); - HResultError(const HResultError& other) = default; - HResultError(HResultError&& other) = default; - HResultError& operator=(const HResultError& other) = default; - HResultError& operator=(HResultError&& other) = default; + explicit HResultError(HRESULT h_result, const std::string_view& message); + + CRU_DEFAULT_COPY(HResultError) + CRU_DEFAULT_MOVE(HResultError) + ~HResultError() override = default; HRESULT GetHResult() const { return h_result_; } @@ -35,17 +34,19 @@ inline void ThrowIfFailed(const HRESULT h_result, class Win32Error : public platform::PlatformException { public: - explicit Win32Error(DWORD error_code); - Win32Error(DWORD error_code, const std::string_view& additional_message); - Win32Error(const Win32Error& other) = default; - Win32Error(Win32Error&& other) = default; - Win32Error& operator=(const Win32Error& other) = default; - Win32Error& operator=(Win32Error&& other) = default; + // ::GetLastError is automatically called to get the error code. + // The same as Win32Error(::GetLastError(), message) + explicit Win32Error(const std::string_view& message); + Win32Error(DWORD error_code, const std::string_view& message); + + CRU_DEFAULT_COPY(Win32Error) + CRU_DEFAULT_MOVE(Win32Error) + ~Win32Error() override = default; - HRESULT GetErrorCode() const { return error_code_; } + DWORD GetErrorCode() const { return error_code_; } private: DWORD error_code_; }; -} // namespace cru::win +} // namespace cru::platform::win |