aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/include/winapi/error.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/winapi/error.hpp')
-rw-r--r--include/winapi/error.hpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/winapi/error.hpp b/include/winapi/error.hpp
index 4b3f1e0..89bcfed 100644
--- a/include/winapi/error.hpp
+++ b/include/winapi/error.hpp
@@ -9,6 +9,8 @@
#include <windows.h>
+#include <sstream>
+#include <stdexcept>
#include <string>
#include <system_error>
@@ -31,5 +33,12 @@ inline const CategoryWindows& category_windows() {
std::system_error windows(DWORD code, const char* function);
+template <typename Ret>
+std::runtime_error custom(Ret ret, const char* function) {
+ std::ostringstream oss;
+ oss << "Function " << function << " failed with error code " << ret;
+ return std::runtime_error{oss.str()};
+}
+
} // namespace error
} // namespace winapi