except: add missing methods to win32_error
This commit is contained in:
parent
a941f4d74e
commit
abce134089
40
except.cpp
40
except.cpp
@ -105,20 +105,34 @@ errno_error::throw_code (int code)
|
||||
using util::win32_error;
|
||||
|
||||
|
||||
win32_error::win32_error (DWORD _id):
|
||||
runtime_error ("Win32 error"),
|
||||
id (_id)
|
||||
//-----------------------------------------------------------------------------
|
||||
win32_error::win32_error (DWORD _code):
|
||||
runtime_error (code_string (_code)),
|
||||
m_code (_code)
|
||||
{
|
||||
CHECK_NEQ (id, (DWORD)ERROR_SUCCESS);
|
||||
CHECK_NEQ (m_code, (DWORD)ERROR_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
win32_error::win32_error (void):
|
||||
runtime_error ("Win32 error"),
|
||||
id (GetLastError ())
|
||||
win32_error (last_code ())
|
||||
{ ; }
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
DWORD
|
||||
win32_error::code (void) const
|
||||
{
|
||||
CHECK_NEQ (id, (DWORD)ERROR_SUCCESS);
|
||||
return m_code;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
DWORD
|
||||
win32_error::last_code (void)
|
||||
{
|
||||
return GetLastError ();
|
||||
}
|
||||
|
||||
|
||||
@ -126,7 +140,7 @@ win32_error::win32_error (void):
|
||||
void
|
||||
win32_error::try_code (void)
|
||||
{
|
||||
try_code (GetLastError ());
|
||||
try_code (last_code ());
|
||||
}
|
||||
|
||||
|
||||
@ -143,16 +157,16 @@ win32_error::try_code (DWORD id)
|
||||
void
|
||||
win32_error::throw_code (void)
|
||||
{
|
||||
throw_code (GetLastError ());
|
||||
throw_code (last_code ());
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void
|
||||
win32_error::throw_code (DWORD id)
|
||||
win32_error::throw_code (DWORD code)
|
||||
{
|
||||
CHECK_NEQ (id, (DWORD)ERROR_SUCCESS);
|
||||
throw win32_error (id);
|
||||
CHECK_NEQ (code, (DWORD)ERROR_SUCCESS);
|
||||
throw win32_error (code);
|
||||
}
|
||||
|
||||
|
||||
@ -160,7 +174,7 @@ win32_error::throw_code (DWORD id)
|
||||
std::string
|
||||
win32_error::code_string (void)
|
||||
{
|
||||
return code_string (GetLastError ());
|
||||
return code_string (last_code ());
|
||||
}
|
||||
|
||||
|
||||
|
24
except.hpp
24
except.hpp
@ -72,20 +72,24 @@ namespace util {
|
||||
|
||||
namespace util {
|
||||
class win32_error : public std::runtime_error {
|
||||
public:
|
||||
DWORD id;
|
||||
public:
|
||||
win32_error (DWORD _code);
|
||||
win32_error ();
|
||||
|
||||
win32_error (DWORD _id);
|
||||
win32_error ();
|
||||
DWORD code (void) const;
|
||||
static DWORD last_code (void);
|
||||
|
||||
static void try_code (void);
|
||||
static void try_code (DWORD);
|
||||
static void try_code (void);
|
||||
static void try_code (DWORD);
|
||||
|
||||
static void throw_code [[gnu::noreturn]] (void);
|
||||
static void throw_code [[gnu::noreturn]] (DWORD);
|
||||
static void throw_code [[gnu::noreturn]] (void);
|
||||
static void throw_code [[gnu::noreturn]] (DWORD);
|
||||
|
||||
static std::string code_string (void);
|
||||
static std::string code_string (DWORD);
|
||||
static std::string code_string (void);
|
||||
static std::string code_string (DWORD);
|
||||
|
||||
private:
|
||||
DWORD m_code;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user