aboutsummaryrefslogtreecommitdiff
path: root/src/exception.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/exception.cpp')
-rw-r--r--src/exception.cpp76
1 files changed, 39 insertions, 37 deletions
diff --git a/src/exception.cpp b/src/exception.cpp
index cb1ca2c7..dbc98453 100644
--- a/src/exception.cpp
+++ b/src/exception.cpp
@@ -1,40 +1,42 @@
#include "exception.hpp"
-#include "format.hpp"
-
-namespace cru
-{
- 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)
- {
-
- }
+#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