aboutsummaryrefslogtreecommitdiff
path: root/src/exception.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2018-11-05 20:54:48 +0800
committercrupest <crupest@outlook.com>2018-11-05 20:54:48 +0800
commit1dab244aaad8694ba37ef43caedd8c8ba0310c00 (patch)
treef70f6489a0f88520a0bdc095cd9713d03f83687b /src/exception.cpp
parent252519effe30881825dd02e26dc41bd9cde34782 (diff)
downloadcru-1dab244aaad8694ba37ef43caedd8c8ba0310c00.tar.gz
cru-1dab244aaad8694ba37ef43caedd8c8ba0310c00.tar.bz2
cru-1dab244aaad8694ba37ef43caedd8c8ba0310c00.zip
...
Diffstat (limited to 'src/exception.cpp')
-rw-r--r--src/exception.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/exception.cpp b/src/exception.cpp
index a1d59ceb..92face96 100644
--- a/src/exception.cpp
+++ b/src/exception.cpp
@@ -1,32 +1,38 @@
#include "exception.h"
-#include <fmt/format.h>
+#include "format.h"
namespace cru
{
- inline std::string HResultMakeMessage(HRESULT h_result, std::optional<std::string> message)
+ 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 fmt::format("An HResultError is thrown. HRESULT: {:#08x}.\nAdditional message: {}\n", h_result, message.value());
+ return Format("An HResultError is thrown. HRESULT: {}.\nAdditional message: {}\n", buffer, message.value());
else
- return fmt::format("An HResultError is thrown. HRESULT: {:#08x}.\n", h_result);
+ return Format("An HResultError is thrown. HRESULT: {}.\n", buffer);
}
- HResultError::HResultError(HRESULT h_result, std::optional<std::string_view> additional_message)
+ 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<std::string> message)
+ 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 fmt::format("Last error code: {:#04x}.\nAdditional message: {}\n", error_code, message.value());
+ return Format("Last error code: {}.\nAdditional message: {}\n", buffer, message.value());
else
- return fmt::format("Last error code: {:#04x}.\n", error_code);
+ return Format("Last error code: {}.\n", buffer);
}
- Win32Error::Win32Error(DWORD error_code, std::optional<std::string_view> additional_message)
+ Win32Error::Win32Error(DWORD error_code, std::optional<MultiByteStringView> additional_message)
: runtime_error(Win32MakeMessage(error_code, std::nullopt)), error_code_(error_code)
{