mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
switch all exceptions to be of type websocketpp::exception
This commit is contained in:
@@ -145,7 +145,7 @@ BOOST_AUTO_TEST_CASE( select_subprotocol ) {
|
||||
|
||||
con->select_subprotocol("foo",ec);
|
||||
BOOST_CHECK_EQUAL( ec , make_error_code(websocketpp::error::server_only) );
|
||||
BOOST_CHECK_THROW( con->select_subprotocol("foo") , websocketpp::lib::error_code );
|
||||
BOOST_CHECK_THROW( con->select_subprotocol("foo") , websocketpp::exception );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( add_subprotocols_invalid ) {
|
||||
@@ -158,11 +158,11 @@ BOOST_AUTO_TEST_CASE( add_subprotocols_invalid ) {
|
||||
|
||||
con->add_subprotocol("",ec);
|
||||
BOOST_CHECK_EQUAL( ec , make_error_code(websocketpp::error::invalid_subprotocol) );
|
||||
BOOST_CHECK_THROW( con->add_subprotocol("") , websocketpp::lib::error_code );
|
||||
BOOST_CHECK_THROW( con->add_subprotocol("") , websocketpp::exception );
|
||||
|
||||
con->add_subprotocol("foo,bar",ec);
|
||||
BOOST_CHECK_EQUAL( ec , make_error_code(websocketpp::error::invalid_subprotocol) );
|
||||
BOOST_CHECK_THROW( con->add_subprotocol("foo,bar") , websocketpp::lib::error_code );
|
||||
BOOST_CHECK_THROW( con->add_subprotocol("foo,bar") , websocketpp::exception );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( add_subprotocols ) {
|
||||
|
||||
@@ -215,7 +215,7 @@ BOOST_AUTO_TEST_CASE( accept_subprotocol_invalid ) {
|
||||
|
||||
std::string o;
|
||||
|
||||
BOOST_CHECK_THROW(o = run_server_test(s,input), websocketpp::lib::error_code);
|
||||
BOOST_CHECK_THROW(o = run_server_test(s,input), websocketpp::exception);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( accept_subprotocol_two ) {
|
||||
|
||||
@@ -538,7 +538,7 @@ public:
|
||||
lib::error_code ec;
|
||||
connection_ptr con = this->get_con_from_hdl(hdl,ec);
|
||||
if (ec) {
|
||||
throw ec;
|
||||
throw exception(ec);
|
||||
}
|
||||
return con;
|
||||
}
|
||||
|
||||
@@ -201,17 +201,17 @@ void connection<config>::ping(const std::string& payload, lib::error_code& ec) {
|
||||
}
|
||||
|
||||
template<typename config>
|
||||
void connection<config>::ping(const std::string& payload) {
|
||||
void connection<config>::ping(std::string const & payload) {
|
||||
lib::error_code ec;
|
||||
ping(payload,ec);
|
||||
if (ec) {
|
||||
throw ec;
|
||||
throw exception(ec);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename config>
|
||||
void connection<config>::handle_pong_timeout(std::string payload, const lib::error_code &
|
||||
ec)
|
||||
void connection<config>::handle_pong_timeout(std::string payload,
|
||||
lib::error_code const & ec)
|
||||
{
|
||||
if (ec) {
|
||||
if (ec == transport::error::operation_aborted) {
|
||||
@@ -229,7 +229,8 @@ void connection<config>::handle_pong_timeout(std::string payload, const lib::err
|
||||
}
|
||||
|
||||
template <typename config>
|
||||
void connection<config>::pong(const std::string& payload, lib::error_code& ec) {
|
||||
void connection<config>::pong(std::string const & payload, lib::error_code & ec)
|
||||
{
|
||||
m_alog.write(log::alevel::devel,"connection pong");
|
||||
|
||||
if (m_state != session::state::open) {
|
||||
@@ -264,11 +265,11 @@ void connection<config>::pong(const std::string& payload, lib::error_code& ec) {
|
||||
}
|
||||
|
||||
template<typename config>
|
||||
void connection<config>::pong(const std::string& payload) {
|
||||
void connection<config>::pong(std::string const & payload) {
|
||||
lib::error_code ec;
|
||||
pong(payload,ec);
|
||||
if (ec) {
|
||||
throw ec;
|
||||
throw exception(ec);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,7 +298,7 @@ void connection<config>::close(close::status::value const code,
|
||||
lib::error_code ec;
|
||||
close(code,reason,ec);
|
||||
if (ec) {
|
||||
throw ec;
|
||||
throw exception(ec);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -423,7 +424,7 @@ connection<config>::get_requested_subprotocols() const {
|
||||
}
|
||||
|
||||
template <typename config>
|
||||
void connection<config>::add_subprotocol(const std::string & value,
|
||||
void connection<config>::add_subprotocol(std::string const & value,
|
||||
lib::error_code & ec)
|
||||
{
|
||||
if (m_is_server) {
|
||||
@@ -443,17 +444,17 @@ void connection<config>::add_subprotocol(const std::string & value,
|
||||
}
|
||||
|
||||
template <typename config>
|
||||
void connection<config>::add_subprotocol(const std::string & value) {
|
||||
void connection<config>::add_subprotocol(std::string const & value) {
|
||||
lib::error_code ec;
|
||||
this->add_subprotocol(value,ec);
|
||||
if (ec) {
|
||||
throw ec;
|
||||
throw exception(ec);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename config>
|
||||
void connection<config>::select_subprotocol(const std::string & value,
|
||||
void connection<config>::select_subprotocol(std::string const & value,
|
||||
lib::error_code & ec)
|
||||
{
|
||||
if (!m_is_server) {
|
||||
@@ -481,24 +482,24 @@ void connection<config>::select_subprotocol(const std::string & value,
|
||||
}
|
||||
|
||||
template <typename config>
|
||||
void connection<config>::select_subprotocol(const std::string & value) {
|
||||
void connection<config>::select_subprotocol(std::string const & value) {
|
||||
lib::error_code ec;
|
||||
this->select_subprotocol(value,ec);
|
||||
if (ec) {
|
||||
throw ec;
|
||||
throw exception(ec);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename config>
|
||||
const std::string &
|
||||
connection<config>::get_request_header(const std::string &key) {
|
||||
connection<config>::get_request_header(std::string const & key) {
|
||||
return m_request.get_header(key);
|
||||
}
|
||||
|
||||
template <typename config>
|
||||
const std::string &
|
||||
connection<config>::get_response_header(const std::string &key) {
|
||||
connection<config>::get_response_header(std::string const & key) {
|
||||
return m_response.get_header(key);
|
||||
}
|
||||
|
||||
@@ -508,9 +509,8 @@ void connection<config>::set_status(http::status_code::value code)
|
||||
//scoped_lock_type lock(m_connection_state_lock);
|
||||
|
||||
if (m_internal_state != istate::PROCESS_HTTP_REQUEST) {
|
||||
throw error::make_error_code(error::invalid_state);
|
||||
//throw exception("Call to set_status from invalid state",
|
||||
// error::INVALID_STATE);
|
||||
throw exception("Call to set_status from invalid state",
|
||||
error::make_error_code(error::invalid_state));
|
||||
}
|
||||
|
||||
m_response.set_status(code);
|
||||
@@ -522,9 +522,8 @@ void connection<config>::set_status(http::status_code::value code,
|
||||
//scoped_lock_type lock(m_connection_state_lock);
|
||||
|
||||
if (m_internal_state != istate::PROCESS_HTTP_REQUEST) {
|
||||
throw error::make_error_code(error::invalid_state);
|
||||
//throw exception("Call to set_status from invalid state",
|
||||
// error::INVALID_STATE);
|
||||
throw exception("Call to set_status from invalid state",
|
||||
error::make_error_code(error::invalid_state));
|
||||
}
|
||||
|
||||
m_response.set_status(code,msg);
|
||||
@@ -534,9 +533,8 @@ void connection<config>::set_body(std::string const & value) {
|
||||
//scoped_lock_type lock(m_connection_state_lock);
|
||||
|
||||
if (m_internal_state != istate::PROCESS_HTTP_REQUEST) {
|
||||
throw error::make_error_code(error::invalid_state);
|
||||
//throw exception("Call to set_status from invalid state",
|
||||
// error::INVALID_STATE);
|
||||
throw exception("Call to set_status from invalid state",
|
||||
error::make_error_code(error::invalid_state));
|
||||
}
|
||||
|
||||
m_response.set_body(value);
|
||||
@@ -553,14 +551,16 @@ void connection<config>::append_header(std::string const & key,
|
||||
// we are setting response headers for an incoming server connection
|
||||
m_response.append_header(key,val);
|
||||
} else {
|
||||
throw error::make_error_code(error::invalid_state);
|
||||
throw exception("Call to append_header from invalid state",
|
||||
error::make_error_code(error::invalid_state));
|
||||
}
|
||||
} else {
|
||||
if (m_internal_state == istate::USER_INIT) {
|
||||
// we are setting initial headers for an outgoing client connection
|
||||
m_request.append_header(key,val);
|
||||
} else {
|
||||
throw error::make_error_code(error::invalid_state);
|
||||
throw exception("Call to append_header from invalid state",
|
||||
error::make_error_code(error::invalid_state));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -575,14 +575,16 @@ void connection<config>::replace_header(std::string const & key,
|
||||
// we are setting response headers for an incoming server connection
|
||||
m_response.replace_header(key,val);
|
||||
} else {
|
||||
throw error::make_error_code(error::invalid_state);
|
||||
throw exception("Call to replace_header from invalid state",
|
||||
error::make_error_code(error::invalid_state));
|
||||
}
|
||||
} else {
|
||||
if (m_internal_state == istate::USER_INIT) {
|
||||
// we are setting initial headers for an outgoing client connection
|
||||
m_request.replace_header(key,val);
|
||||
} else {
|
||||
throw error::make_error_code(error::invalid_state);
|
||||
throw exception("Call to replace_header from invalid state",
|
||||
error::make_error_code(error::invalid_state));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -596,14 +598,16 @@ void connection<config>::remove_header(std::string const & key)
|
||||
// we are setting response headers for an incoming server connection
|
||||
m_response.remove_header(key);
|
||||
} else {
|
||||
throw error::make_error_code(error::invalid_state);
|
||||
throw exception("Call to remove_header from invalid state",
|
||||
error::make_error_code(error::invalid_state));
|
||||
}
|
||||
} else {
|
||||
if (m_internal_state == istate::USER_INIT) {
|
||||
// we are setting initial headers for an outgoing client connection
|
||||
m_request.remove_header(key);
|
||||
} else {
|
||||
throw error::make_error_code(error::invalid_state);
|
||||
throw exception("Call to remove_header from invalid state",
|
||||
error::make_error_code(error::invalid_state));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -645,9 +649,8 @@ void connection<config>::handle_transport_init(lib::error_code const & ec) {
|
||||
scoped_lock_type lock(m_connection_state_lock);
|
||||
|
||||
if (m_internal_state != istate::TRANSPORT_INIT) {
|
||||
throw error::make_error_code(error::invalid_state);
|
||||
//throw exception("handle_transport_init must be called from transport init state",
|
||||
// error::INVALID_STATE);
|
||||
throw exception("handle_transport_init must be called from transport init state",
|
||||
error::make_error_code(error::invalid_state));
|
||||
}
|
||||
|
||||
if (!ec) {
|
||||
@@ -1654,8 +1657,7 @@ void connection<config>::atomic_state_change(istate_type req, istate_type dest,
|
||||
scoped_lock_type lock(m_connection_state_lock);
|
||||
|
||||
if (m_internal_state != req) {
|
||||
throw error::make_error_code(error::invalid_state);
|
||||
//throw exception(msg,error::INVALID_STATE);
|
||||
throw exception(msg,error::make_error_code(error::invalid_state));
|
||||
}
|
||||
|
||||
m_internal_state = dest;
|
||||
@@ -1669,8 +1671,7 @@ void connection<config>::atomic_state_change(istate_type internal_req,
|
||||
scoped_lock_type lock(m_connection_state_lock);
|
||||
|
||||
if (m_internal_state != internal_req || m_state != external_req) {
|
||||
throw error::make_error_code(error::invalid_state);
|
||||
//throw exception(msg,error::INVALID_STATE);
|
||||
throw exception(msg,error::make_error_code(error::invalid_state));
|
||||
}
|
||||
|
||||
m_internal_state = internal_dest;
|
||||
@@ -1683,8 +1684,7 @@ void connection<config>::atomic_state_check(istate_type req, std::string msg)
|
||||
scoped_lock_type lock(m_connection_state_lock);
|
||||
|
||||
if (m_internal_state != req) {
|
||||
throw error::make_error_code(error::invalid_state);
|
||||
//throw exception(msg,error::INVALID_STATE);
|
||||
throw exception(msg,error::make_error_code(error::invalid_state));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ template <typename connection, typename config>
|
||||
void endpoint<connection,config>::interrupt(connection_hdl hdl) {
|
||||
lib::error_code ec;
|
||||
interrupt(hdl,ec);
|
||||
if (ec) { throw ec; }
|
||||
if (ec) { throw exception(ec); }
|
||||
}
|
||||
|
||||
template <typename connection, typename config>
|
||||
@@ -120,7 +120,7 @@ template <typename connection, typename config>
|
||||
void endpoint<connection,config>::pause_reading(connection_hdl hdl) {
|
||||
lib::error_code ec;
|
||||
pause_reading(hdl,ec);
|
||||
if (ec) { throw ec; }
|
||||
if (ec) { throw exception(ec); }
|
||||
}
|
||||
|
||||
template <typename connection, typename config>
|
||||
@@ -136,7 +136,7 @@ template <typename connection, typename config>
|
||||
void endpoint<connection,config>::resume_reading(connection_hdl hdl) {
|
||||
lib::error_code ec;
|
||||
resume_reading(hdl,ec);
|
||||
if (ec) { throw ec; }
|
||||
if (ec) { throw exception(ec); }
|
||||
}
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ void endpoint<connection,config>::send(connection_hdl hdl, std::string const & p
|
||||
{
|
||||
lib::error_code ec;
|
||||
send(hdl,payload,op,ec);
|
||||
if (ec) { throw ec; }
|
||||
if (ec) { throw exception(ec); }
|
||||
}
|
||||
|
||||
template <typename connection, typename config>
|
||||
@@ -175,7 +175,7 @@ void endpoint<connection,config>::send(connection_hdl hdl, void const * payload,
|
||||
{
|
||||
lib::error_code ec;
|
||||
send(hdl,payload,len,op,ec);
|
||||
if (ec) { throw ec; }
|
||||
if (ec) { throw exception(ec); }
|
||||
}
|
||||
|
||||
template <typename connection, typename config>
|
||||
@@ -191,7 +191,7 @@ template <typename connection, typename config>
|
||||
void endpoint<connection,config>::send(connection_hdl hdl, message_ptr msg) {
|
||||
lib::error_code ec;
|
||||
send(hdl,msg,ec);
|
||||
if (ec) { throw ec; }
|
||||
if (ec) { throw exception(ec); }
|
||||
}
|
||||
|
||||
template <typename connection, typename config>
|
||||
@@ -210,7 +210,7 @@ void endpoint<connection,config>::close(connection_hdl hdl, close::status::value
|
||||
{
|
||||
lib::error_code ec;
|
||||
close(hdl,code,reason,ec);
|
||||
if (ec) { throw ec; }
|
||||
if (ec) { throw exception(ec); }
|
||||
}
|
||||
|
||||
template <typename connection, typename config>
|
||||
@@ -227,7 +227,7 @@ void endpoint<connection,config>::ping(connection_hdl hdl, std::string const & p
|
||||
{
|
||||
lib::error_code ec;
|
||||
ping(hdl,payload,ec);
|
||||
if (ec) { throw ec; }
|
||||
if (ec) { throw exception(ec); }
|
||||
}
|
||||
|
||||
template <typename connection, typename config>
|
||||
@@ -244,7 +244,7 @@ void endpoint<connection,config>::pong(connection_hdl hdl, std::string const & p
|
||||
{
|
||||
lib::error_code ec;
|
||||
pong(hdl,payload,ec);
|
||||
if (ec) { throw ec; }
|
||||
if (ec) { throw exception(ec); }
|
||||
}
|
||||
|
||||
} // namespace websocketpp
|
||||
|
||||
@@ -129,7 +129,7 @@ public:
|
||||
lib::error_code ec;
|
||||
start_accept(ec);
|
||||
if (ec) {
|
||||
throw ec;
|
||||
throw exception(ec);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ public:
|
||||
*
|
||||
* @param ec A status value
|
||||
*/
|
||||
void set_proxy(const std::string & uri, lib::error_code & ec) {
|
||||
void set_proxy(std::string const & uri, lib::error_code & ec) {
|
||||
// TODO: return errors for illegal URIs here?
|
||||
// TODO: should https urls be illegal for the moment?
|
||||
m_proxy = uri;
|
||||
@@ -174,10 +174,10 @@ public:
|
||||
}
|
||||
|
||||
/// Set the proxy to connect through (exception)
|
||||
void set_proxy(const std::string & uri) {
|
||||
void set_proxy(std::string const & uri) {
|
||||
lib::error_code ec;
|
||||
set_proxy(uri,ec);
|
||||
if (ec) { throw ec; }
|
||||
if (ec) { throw exception(ec); }
|
||||
}
|
||||
|
||||
/// Set the basic auth credentials to use (exception free)
|
||||
@@ -193,8 +193,8 @@ public:
|
||||
*
|
||||
* @param ec A status value
|
||||
*/
|
||||
void set_proxy_basic_auth(const std::string & username, const
|
||||
std::string & password, lib::error_code & ec)
|
||||
void set_proxy_basic_auth(std::string const & username, std::string const &
|
||||
password, lib::error_code & ec)
|
||||
{
|
||||
if (!m_proxy_data) {
|
||||
ec = make_error_code(websocketpp::error::invalid_state);
|
||||
@@ -208,12 +208,12 @@ public:
|
||||
}
|
||||
|
||||
/// Set the basic auth credentials to use (exception)
|
||||
void set_proxy_basic_auth(const std::string & username, const
|
||||
std::string & password)
|
||||
void set_proxy_basic_auth(std::string const & username, std::string const &
|
||||
password)
|
||||
{
|
||||
lib::error_code ec;
|
||||
set_proxy_basic_auth(username,password,ec);
|
||||
if (ec) { throw ec; }
|
||||
if (ec) { throw exception(ec); }
|
||||
}
|
||||
|
||||
/// Set the proxy timeout duration (exception free)
|
||||
@@ -240,7 +240,7 @@ public:
|
||||
void set_proxy_timeout(long duration) {
|
||||
lib::error_code ec;
|
||||
set_proxy_timeout(duration,ec);
|
||||
if (ec) { throw ec; }
|
||||
if (ec) { throw exception(ec); }
|
||||
}
|
||||
|
||||
const std::string & get_proxy() const {
|
||||
|
||||
@@ -194,9 +194,7 @@ public:
|
||||
void init_asio(io_service_ptr ptr) {
|
||||
lib::error_code ec;
|
||||
init_asio(ptr,ec);
|
||||
if (ec) {
|
||||
throw ec;
|
||||
}
|
||||
if (ec) { throw exception(ec); }
|
||||
}
|
||||
|
||||
/// Initialize asio transport with internal io_service (exception free)
|
||||
@@ -365,9 +363,7 @@ public:
|
||||
void listen(boost::asio::ip::tcp::endpoint const & ep) {
|
||||
lib::error_code ec;
|
||||
listen(ep,ec);
|
||||
if (ec) {
|
||||
throw ec;
|
||||
}
|
||||
if (ec) { throw exception(ec); }
|
||||
}
|
||||
|
||||
/// Set up endpoint for listening with protocol and port (exception free)
|
||||
@@ -497,9 +493,7 @@ public:
|
||||
{
|
||||
lib::error_code ec;
|
||||
listen(host,service,ec);
|
||||
if (ec) {
|
||||
throw ec;
|
||||
}
|
||||
if (ec) { throw exception(ec); }
|
||||
}
|
||||
|
||||
/// Stop listening (exception free)
|
||||
@@ -534,9 +528,7 @@ public:
|
||||
void stop_listening() {
|
||||
lib::error_code ec;
|
||||
stop_listening(ec);
|
||||
if (ec) {
|
||||
throw ec;
|
||||
}
|
||||
if (ec) { throw exception(ec); }
|
||||
}
|
||||
|
||||
/// Check if the endpoint is listening
|
||||
@@ -720,9 +712,7 @@ public:
|
||||
void async_accept(transport_con_ptr tcon, accept_handler callback) {
|
||||
lib::error_code ec;
|
||||
async_accept(tcon,callback,ec);
|
||||
if (ec) {
|
||||
throw ec;
|
||||
}
|
||||
if (ec) { throw exception(ec); }
|
||||
}
|
||||
protected:
|
||||
/// Initialize logging
|
||||
|
||||
Reference in New Issue
Block a user