diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2016-09-15 19:32:24 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2016-09-15 19:32:24 +0300 |
commit | 94ae6a34b0cb90ee387c6e9a86ccd1998f8864d6 (patch) | |
tree | 67e27c98fb4399f65aeee74b116dfed1565a6e8d /error.h | |
download | privilege-check-94ae6a34b0cb90ee387c6e9a86ccd1998f8864d6.tar.gz privilege-check-94ae6a34b0cb90ee387c6e9a86ccd1998f8864d6.zip |
initial commit
Diffstat (limited to '')
-rw-r--r-- | error.h | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -0,0 +1,26 @@ +#pragma once + +#include <Windows.h> + +#include <system_error> + +typedef std::system_error Error; + +namespace error +{ + inline void raise(const char* function_name) + { + const auto ec = GetLastError(); + throw std::system_error(ec, std::system_category(), function_name); + } + + void report(const Error& e) + { + MessageBoxA(NULL, e.what(), NULL, MB_OK); + } + + int get_code(const Error& e) + { + return e.code().value(); + } +} |