From fa9fac1d92c40258b276c6e94cf74b8f3d6160bf Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Mon, 10 Aug 2015 15:42:58 +1000 Subject: [PATCH] except: add throw_code for win32_error --- except.cpp | 33 +++++++++++++++++++++++++-------- except.hpp | 5 ++++- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/except.cpp b/except.cpp index 6e5358c5..5625e04e 100644 --- a/except.cpp +++ b/except.cpp @@ -105,20 +105,37 @@ win32_error::win32_error (void): } +/////////////////////////////////////////////////////////////////////////////// void -win32_error::try_code (void) { - const auto id = GetLastError (); - if (id == ERROR_SUCCESS) - return; - - throw win32_error (id); +win32_error::try_code (void) +{ + try_code (GetLastError ()); } //----------------------------------------------------------------------------- void -win32_error::throw_code (void) { - const auto id = GetLastError (); +win32_error::try_code (DWORD id) +{ + if (id == ERROR_SUCCESS) + return; + + throw_code (id); +} + + +//----------------------------------------------------------------------------- +void +win32_error::throw_code (void) +{ + throw_code (GetLastError ()); +} + + +//----------------------------------------------------------------------------- +void +win32_error::throw_code (DWORD id) +{ CHECK (id != ERROR_SUCCESS); throw win32_error (id); } diff --git a/except.hpp b/except.hpp index 73b64ea9..0d211100 100644 --- a/except.hpp +++ b/except.hpp @@ -74,7 +74,10 @@ namespace util { win32_error (); static void try_code (void); - static void throw_code (void); + static void try_code (DWORD); + + static void throw_code [[gnu::noreturn]] (void); + static void throw_code [[gnu::noreturn]] (DWORD); }; } #endif