posix/except: add templated error_code

This commit is contained in:
Danny Robson 2018-04-01 14:43:28 +10:00
parent cc54d23998
commit 5b9eae9b25
2 changed files with 10 additions and 2 deletions

View File

@ -29,7 +29,6 @@ using util::posix::error;
///
/// The error value MUST be an error at construction time.
error::error (int _code):
std::runtime_error (::strerror (_code)),
m_code (_code)
{
CHECK_NEQ (_code, 0);

View File

@ -25,7 +25,7 @@ namespace util::posix {
///
/// Ideally this would be named `errno' but that symbol is permitted to
/// be a macro and significantly complicates symbol resolution either way.
class error : public std::runtime_error {
class error : public std::exception {
public:
explicit error (int code);
error ();
@ -52,6 +52,15 @@ namespace util::posix {
};
template <int CodeV>
struct error_code : public error {
error_code ():
error (CodeV)
{ ; }
};
class eai : public std::runtime_error {
public:
explicit eai (int code);