3 * - By John Hodge (thePowersGang)
6 * - ::std::system_error and other helpers
8 #include <system_error>
13 system_error::system_error(::std::error_code ec):
15 m_what_str( (::std::string)ec.category().name() + ":" + ec.message())
17 ::_sys::debug("system_error(%s:%s)", ec.category().name(), ec.message().c_str());
19 system_error::system_error(::std::error_code ec, const ::std::string& what_arg):
23 m_what_str += what_arg;
25 system_error::system_error(::std::error_code ec, const char* what_arg):
29 m_what_str += what_arg;
31 system_error::system_error(int ev, const ::std::error_category& ecat):
32 system_error( ::std::error_code(ev, ecat) )
35 system_error::system_error(int ev, const ::std::error_category& ecat, const ::std::string& what_arg):
36 system_error(ev, ecat)
39 m_what_str += what_arg;
41 system_error::system_error(int ev, const ::std::error_category& ecat, const char* what_arg):
42 system_error(ev, ecat)
45 m_what_str += what_arg;
48 system_error::~system_error() noexcept
52 const char* system_error::what() const noexcept
54 return m_what_str.c_str();
58 bool error_category::equivalent(const error_code& code, int valcond) const noexcept {
59 return *this == code.category() && code.value() == valcond;
63 class class_generic_category:
67 class_generic_category() {
69 ~class_generic_category() noexcept {
71 const char *name() const noexcept {
74 ::std::string message(int val) const {
75 return ::std::string( ::strerror(val) );
79 const ::std::error_category& generic_category() noexcept
81 return g_generic_category;
85 class class_system_category:
89 class_system_category() {
91 ~class_system_category() noexcept {
93 const char *name() const noexcept {
96 ::std::string message(int val) const {
97 return ::std::string( ::strerror(val) );
101 const ::std::error_category& system_category() noexcept
103 return g_system_category;