except: add code and last_code accessors to errno_error

This commit is contained in:
Danny Robson 2016-04-27 16:06:58 +10:00
parent 354573f369
commit a941f4d74e
2 changed files with 21 additions and 2 deletions

View File

@ -47,12 +47,28 @@ errno_error::errno_error ():
}
///////////////////////////////////////////////////////////////////////////////
int
errno_error::last_code (void)
{
return errno;
}
//-----------------------------------------------------------------------------
int
errno_error::code (void) const
{
return m_code;
}
///////////////////////////////////////////////////////////////////////////////
/// Throw an errno_error exception if errno currently signals an error.
void
errno_error::try_code (void)
{
try_code (errno);
try_code (last_code ());
}
@ -70,7 +86,7 @@ errno_error::try_code (int code)
void
errno_error::throw_code (void)
{
throw_code (errno);
throw_code (last_code ());
}

View File

@ -53,6 +53,9 @@ namespace util {
errno_error (int code);
errno_error ();
int code (void) const;
static int last_code (void);
static void try_code (void);
static void try_code (int code);