From 770b32275ce36512f7e31d6bf81fcfa395810722 Mon Sep 17 00:00:00 2001 From: Peter Thorson Date: Wed, 5 Mar 2014 08:30:08 -0600 Subject: [PATCH] updates websocketpp::exception to wrap lib::error_code --- websocketpp/error.hpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) 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