aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/error.hpp9
-rw-r--r--src/main.cpp11
2 files changed, 8 insertions, 12 deletions
diff --git a/src/error.hpp b/src/error.hpp
index 2ea7f85..ad43307 100644
--- a/src/error.hpp
+++ b/src/error.hpp
@@ -8,10 +8,15 @@ typedef std::system_error Error;
namespace error
{
- inline void raise(const char* function_name)
+ Error make(const char* function_name)
{
const auto ec = GetLastError();
- throw std::system_error(ec, std::system_category(), function_name);
+ return {static_cast<int>(ec), std::system_category(), function_name};
+ }
+
+ inline void raise(const char* function_name)
+ {
+ throw make(function_name);
}
void report(const Error& e)
diff --git a/src/main.cpp b/src/main.cpp
index 1777d79..2045ef6 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -194,16 +194,7 @@ int APIENTRY wWinMain(
switch (ret)
{
case -1:
- try
- {
- error::raise("DialogBoxW");
- }
- catch (const Error& e)
- {
- error::report(e);
- return 1;
- }
-
+ error::report(error::make("DialogBoxW"));
default:
return static_cast<int>(ret);
}