aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/include/winapi/error.hpp
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2020-10-15 03:29:20 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2020-10-15 10:39:54 +0300
commitd24ef6058f2d60100be44507d46014ef30010493 (patch)
treeb355d18a2b0f963a6fad9af9f6fa67b2850d31cf /include/winapi/error.hpp
parenttest: add test utility "args" (diff)
downloadwinapi-common-d24ef6058f2d60100be44507d46014ef30010493.tar.gz
winapi-common-d24ef6058f2d60100be44507d46014ef30010493.zip
WIP: add simple Process class
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