added try_code routines for errno_error

This commit is contained in:
Danny Robson 2011-05-25 23:02:15 +10:00
parent 745e06d1af
commit 547fdc629a
2 changed files with 19 additions and 1 deletions

View File

@ -18,6 +18,7 @@
*/
#include "except.hpp"
#include "debug.hpp"
#include <cstring>
#include <cerrno>
@ -34,4 +35,18 @@ errno_error::errno_error (int _errno):
errno_error::errno_error ():
runtime_error (strerror (errno)),
id (errno)
{ ; }
{
check_hard (errno != 0);
}
void
errno_error::try_code ()
{ try_code (errno); }
void
errno_error::try_code(int code) {
if (code != 0)
throw errno_error(code);
}

View File

@ -45,6 +45,9 @@ class errno_error : public std::runtime_error {
int id;
errno_error (int _errno);
errno_error ();
void try_code (void);
void try_code (int code);
};