From bd5c17313f043c4478619339e371977f0a7dafce Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Fri, 16 Sep 2016 04:15:51 +0300 Subject: refactoring --- src/error.hpp | 9 +++++++-- src/main.cpp | 11 +---------- 2 files changed, 8 insertions(+), 12 deletions(-) (limited to 'src') 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(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(ret); } -- cgit v1.2.3