posix/except: add 'what' member for code class

This commit is contained in:
Danny Robson 2018-07-05 13:44:03 +10:00
parent a7ce62cd66
commit a4844fa7ed
2 changed files with 15 additions and 3 deletions

View File

@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* Copyright 2010, 2017, * Copyright 2010-2018
* Danny Robson <danny@nerdcruft.net> * Danny Robson <danny@nerdcruft.net>
*/ */
@ -98,6 +98,16 @@ error::throw_code (int code)
} }
///////////////////////////////////////////////////////////////////////////////
const char*
error::what (void) const noexcept
{
return strerror (m_code);
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
using util::posix::eai; using util::posix::eai;

View File

@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
* *
* Copyright 2010, 2017, * Copyright 2010-2018
* Danny Robson <danny@nerdcruft.net> * Danny Robson <danny@nerdcruft.net>
*/ */
@ -39,6 +39,8 @@ namespace util::posix {
static void throw_code [[gnu::noreturn]] (void); static void throw_code [[gnu::noreturn]] (void);
static void throw_code [[gnu::noreturn]] (int code); static void throw_code [[gnu::noreturn]] (int code);
virtual const char* what (void) const noexcept final override;
template <typename T> template <typename T>
static T try_value (T value) static T try_value (T value)
{ {
@ -48,7 +50,7 @@ namespace util::posix {
} }
private: private:
int m_code; int const m_code;
}; };