diff --git a/websocketpp/error.hpp b/websocketpp/error.hpp index 45a345849f..df6badfc0d 100644 --- a/websocketpp/error.hpp +++ b/websocketpp/error.hpp @@ -216,21 +216,30 @@ namespace websocketpp { class exception : public std::exception { public: - exception(std::string const & msg, error::value p_code = error::general) - : m_msg(msg), m_code(p_code) {} + exception(std::string const & msg, lib::error_code ec = make_error_code(error::general)) + : m_msg(msg), m_code(ec) + {} + + explicit exception(lib::error_code ec) + : m_code(ec) + {} ~exception() throw() {} virtual char const * what() const throw() { - return m_msg.c_str(); + if (m_msg.empty()) { + return m_code.message().c_str(); + } else { + return m_msg.c_str(); + } } - error::value code() const throw() { + lib::error_code code() const throw() { return m_code; } std::string m_msg; - error::value m_code; + lib::error_code m_code; }; } // namespace websocketpp