aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/error.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/error.hpp')
-rw-r--r--src/error.hpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/error.hpp b/src/error.hpp
index b8ba468..40522bb 100644
--- a/src/error.hpp
+++ b/src/error.hpp
@@ -5,6 +5,8 @@
#pragma once
+#include <Windows.h>
+
#include <exception>
#include <system_error>
@@ -12,11 +14,24 @@ typedef std::system_error Error;
namespace error
{
- Error make(const char* function_name);
+ inline Error make(const char* function_name)
+ {
+ const auto ec = GetLastError();
+ return {static_cast<int>(ec), std::system_category(), function_name};
+ }
- void raise(const char* function_name);
+ inline void raise(const char* function_name)
+ {
+ throw make(function_name);
+ }
- void report(const std::exception&);
+ inline void report(const std::exception& e)
+ {
+ MessageBoxA(NULL, e.what(), NULL, MB_OK);
+ }
- int get_code(const Error&);
+ inline int get_code(const Error& e)
+ {
+ return e.code().value();
+ }
}