aboutsummaryrefslogtreecommitdiff
path: root/include/cru/win/exception.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/cru/win/exception.hpp')
-rw-r--r--include/cru/win/exception.hpp29
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