summaryrefslogtreecommitdiff
path: root/common/rawaccel-error.hpp
diff options
context:
space:
mode:
authora1xd <[email protected]>2021-04-01 01:51:31 -0400
committera1xd <[email protected]>2021-04-01 01:51:31 -0400
commit14bde56daf188bfc027dc8ead5b45ec0aa1109d6 (patch)
tree6c674efea62c4e945e4d8ed3e947189742486015 /common/rawaccel-error.hpp
parentrefactor lut/motivity (diff)
downloadrawaccel-14bde56daf188bfc027dc8ead5b45ec0aa1109d6.tar.xz
rawaccel-14bde56daf188bfc027dc8ead5b45ec0aa1109d6.zip
update rest
grapher is still broken refactored io / error handling a bit
Diffstat (limited to 'common/rawaccel-error.hpp')
-rw-r--r--common/rawaccel-error.hpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/common/rawaccel-error.hpp b/common/rawaccel-error.hpp
index cdbe1e5..a9cb7b8 100644
--- a/common/rawaccel-error.hpp
+++ b/common/rawaccel-error.hpp
@@ -1,11 +1,12 @@
#pragma once
-#include <stdexcept>
+#include <system_error>
+#include <string>
namespace rawaccel {
- class error : public std::runtime_error {
- using std::runtime_error::runtime_error;
+ class error : public std::runtime_error {
+ using std::runtime_error::runtime_error;
};
class io_error : public error {
@@ -14,7 +15,25 @@ namespace rawaccel {
class install_error : public io_error {
public:
- install_error() : io_error("Raw Accel driver is not installed, run installer.exe") {}
+ install_error() :
+ io_error("Raw Accel is not installed, run installer.exe") {}
+ };
+
+ class sys_error : public io_error {
+ public:
+ sys_error(const char* msg, DWORD code = GetLastError()) :
+ io_error(build_msg(code, msg)) {}
+
+ static std::string build_msg(DWORD code, const char* msg)
+ {
+ std::string ret =
+ std::system_error(code, std::system_category(), msg).what();
+ ret += " (";
+ ret += std::to_string(code);
+ ret += ")";
+ return ret;
+ }
+
};
}