From 213451370d312c7c9ab2e69ef3da861dff255368 Mon Sep 17 00:00:00 2001 From: Peter Thorson Date: Fri, 8 Mar 2013 08:45:40 -0600 Subject: [PATCH] adds an overload of get_con_from_hdl that throws --- websocketpp/endpoint.hpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/websocketpp/endpoint.hpp b/websocketpp/endpoint.hpp index c5af1e0d5b..cb52057f8f 100644 --- a/websocketpp/endpoint.hpp +++ b/websocketpp/endpoint.hpp @@ -284,7 +284,7 @@ public: void close(connection_hdl hdl, const close::status::value code, const std::string & reason); - /// Retrieves a connection_ptr from a connection_hdl + /// Retrieves a connection_ptr from a connection_hdl (exception free) /** * Converting a weak pointer to shared_ptr is not thread safe because the * pointer could be deleted at any time. @@ -307,6 +307,16 @@ public: } return con; } + + /// Retrieves a connection_ptr from a connection_hdl (exception version) + connection_ptr get_con_from_hdl(connection_hdl hdl) { + lib::error_code ec; + connection_ptr con = this->get_con_from_hdl(hdl,ec); + if (ec) { + throw ec; + } + return con; + } protected: