diff options
author | crupest <crupest@outlook.com> | 2019-06-27 00:18:48 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-06-27 00:18:48 +0800 |
commit | baa7cf141b8121473edceae16c1a20a6d47bd202 (patch) | |
tree | 9349633a9d0bc286fe29f480bd70e4c2ad1f3075 /src/win/graph/direct/exception.cpp | |
parent | f404a3b2eb7bb9865d0c6f938538899996a53d8c (diff) | |
download | cru-baa7cf141b8121473edceae16c1a20a6d47bd202.tar.gz cru-baa7cf141b8121473edceae16c1a20a6d47bd202.tar.bz2 cru-baa7cf141b8121473edceae16c1a20a6d47bd202.zip |
......
Diffstat (limited to 'src/win/graph/direct/exception.cpp')
-rw-r--r-- | src/win/graph/direct/exception.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/win/graph/direct/exception.cpp b/src/win/graph/direct/exception.cpp new file mode 100644 index 00000000..23c267c1 --- /dev/null +++ b/src/win/graph/direct/exception.cpp @@ -0,0 +1,29 @@ +#include "cru/win/graph/direct/exception.hpp" + +#include "cru/common/format.hpp" + +namespace cru::platform::graph::win::direct { +using util::Format; + +inline std::string HResultMakeMessage(HRESULT h_result, + const std::string_view* message) { + char buffer[10]; + sprintf_s(buffer, "%#08x", h_result); + + if (message) + return Format( + "An HResultError is thrown. HRESULT: {}.\nAdditional message: {}\n", + buffer, *message); + else + return Format("An HResultError is thrown. HRESULT: {}.\n", buffer); +} + +HResultError::HResultError(HRESULT h_result) + : PlatformException(HResultMakeMessage(h_result, nullptr)), + h_result_(h_result) {} + +HResultError::HResultError(HRESULT h_result, + const std::string_view& additional_message) + : PlatformException(HResultMakeMessage(h_result, &additional_message)), + h_result_(h_result) {} +} // namespace cru::platform::graph::win::direct |