aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2016-09-16 04:15:51 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2016-09-16 04:15:51 +0300
commitbd5c17313f043c4478619339e371977f0a7dafce (patch)
treea77d7d58a91a0ef0582b145b9d1b42678ef56bae
parentmove source files to src/ (diff)
downloadprivilege-check-bd5c17313f043c4478619339e371977f0a7dafce.tar.gz
privilege-check-bd5c17313f043c4478619339e371977f0a7dafce.zip
refactoring
Diffstat (limited to '')
-rw-r--r--src/error.hpp9
-rw-r--r--src/main.cpp11
2 files changed, 8 insertions, 12 deletions
diff --git a/src/error.hpp b/src/error.hpp
index 2ea7f85..ad43307 100644
--- a/src/error.hpp
+++ b/src/error.hpp
@@ -8,10 +8,15 @@ typedef std::system_error Error;
namespace error
{
- inline void raise(const char* function_name)
+ Error make(const char* function_name)
{
const auto ec = GetLastError();
- throw std::system_error(ec, std::system_category(), function_name);
+ return {static_cast<int>(ec), std::system_category(), function_name};
+ }
+
+ inline void raise(const char* function_name)
+ {
+ throw make(function_name);
}
void report(const Error& e)
diff --git a/src/main.cpp b/src/main.cpp
index 1777d79..2045ef6 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -194,16 +194,7 @@ int APIENTRY wWinMain(
switch (ret)
{
case -1:
- try
- {
- error::raise("DialogBoxW");
- }
- catch (const Error& e)
- {
- error::report(e);
- return 1;
- }
-
+ error::report(error::make("DialogBoxW"));
default:
return static_cast<int>(ret);
}