diff options
author | crupest <crupest@outlook.com> | 2019-03-31 17:14:47 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-03-31 17:14:47 +0800 |
commit | fbfd90255731954fb80483f4ba7188d3611fafec (patch) | |
tree | 8e3283c911d7aec76130d6a1dc7f5d8a85512b59 /src/exception.cpp | |
parent | 877f65e2e2c40eecc7cfeb194dc9d391af60711b (diff) | |
download | cru-fbfd90255731954fb80483f4ba7188d3611fafec.tar.gz cru-fbfd90255731954fb80483f4ba7188d3611fafec.tar.bz2 cru-fbfd90255731954fb80483f4ba7188d3611fafec.zip |
...
Diffstat (limited to 'src/exception.cpp')
-rw-r--r-- | src/exception.cpp | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/src/exception.cpp b/src/exception.cpp deleted file mode 100644 index dbc98453..00000000 --- a/src/exception.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "exception.hpp" - -#include "util/format.hpp" - -namespace cru { -using util::Format; - -inline std::string HResultMakeMessage( - HRESULT h_result, std::optional<MultiByteStringView> message) { - char buffer[10]; - sprintf_s(buffer, "%#08x", h_result); - - if (message.has_value()) - return Format( - "An HResultError is thrown. HRESULT: {}.\nAdditional message: {}\n", - buffer, message.value()); - else - return Format("An HResultError is thrown. HRESULT: {}.\n", buffer); -} - -HResultError::HResultError( - HRESULT h_result, std::optional<MultiByteStringView> additional_message) - : runtime_error(HResultMakeMessage(h_result, std::nullopt)), - h_result_(h_result) {} - -inline std::string Win32MakeMessage( - DWORD error_code, std::optional<MultiByteStringView> message) { - char buffer[10]; - sprintf_s(buffer, "%#04x", error_code); - - if (message.has_value()) - return Format("Last error code: {}.\nAdditional message: {}\n", buffer, - message.value()); - else - return Format("Last error code: {}.\n", buffer); -} - -Win32Error::Win32Error(DWORD error_code, - std::optional<MultiByteStringView> additional_message) - : runtime_error(Win32MakeMessage(error_code, std::nullopt)), - error_code_(error_code) {} -} // namespace cru |