From 5b9eae9b259437e7832d9311566a015e9311a7e1 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Sun, 1 Apr 2018 14:43:28 +1000 Subject: [PATCH] posix/except: add templated error_code --- posix/except.cpp | 1 - posix/except.hpp | 11 ++++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/posix/except.cpp b/posix/except.cpp index ef416417..a45694b1 100644 --- a/posix/except.cpp +++ b/posix/except.cpp @@ -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); diff --git a/posix/except.hpp b/posix/except.hpp index 44380baf..f3b03db6 100644 --- a/posix/except.hpp +++ b/posix/except.hpp @@ -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 + struct error_code : public error { + error_code (): + error (CodeV) + { ; } + }; + + + class eai : public std::runtime_error { public: explicit eai (int code);