From a4844fa7ede96a4f94ca93897be9c3c2702ad8a1 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Thu, 5 Jul 2018 13:44:03 +1000 Subject: [PATCH] posix/except: add 'what' member for code class --- posix/except.cpp | 12 +++++++++++- posix/except.hpp | 6 ++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/posix/except.cpp b/posix/except.cpp index a45694b1..4feae9f2 100644 --- a/posix/except.cpp +++ b/posix/except.cpp @@ -11,7 +11,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * Copyright 2010, 2017, + * Copyright 2010-2018 * Danny Robson */ @@ -98,6 +98,16 @@ error::throw_code (int code) } +/////////////////////////////////////////////////////////////////////////////// +const char* +error::what (void) const noexcept +{ + return strerror (m_code); +} + + + + /////////////////////////////////////////////////////////////////////////////// using util::posix::eai; diff --git a/posix/except.hpp b/posix/except.hpp index f3b03db6..fb75d913 100644 --- a/posix/except.hpp +++ b/posix/except.hpp @@ -11,7 +11,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * Copyright 2010, 2017, + * Copyright 2010-2018 * Danny Robson */ @@ -39,6 +39,8 @@ namespace util::posix { static void throw_code [[gnu::noreturn]] (void); static void throw_code [[gnu::noreturn]] (int code); + virtual const char* what (void) const noexcept final override; + template static T try_value (T value) { @@ -48,7 +50,7 @@ namespace util::posix { } private: - int m_code; + int const m_code; };