mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
improves client connect error handling. Fixes #52
This commit is contained in:
@@ -153,7 +153,9 @@ namespace websocketpp {
|
||||
GENERIC = 0,
|
||||
// send attempted when endpoint write queue was full
|
||||
SEND_QUEUE_FULL = 1,
|
||||
PAYLOAD_VIOLATION = 2
|
||||
PAYLOAD_VIOLATION = 2,
|
||||
ENDPOINT_UNSECURE = 3,
|
||||
ENDPOINT_UNAVAILABLE = 4
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -253,18 +253,23 @@ private:
|
||||
template <class endpoint>
|
||||
typename endpoint_traits<endpoint>::connection_ptr
|
||||
client<endpoint>::connect(const std::string& u) {
|
||||
// TODO: will throw, should we catch and wrap?
|
||||
// TODO: uri constructor will throw, should we catch and wrap?
|
||||
uri_ptr location(new uri(u));
|
||||
|
||||
if (location->get_secure() && !m_endpoint.is_secure()) {
|
||||
// TODO: what kind of exception does client throw?
|
||||
throw "";
|
||||
throw websocketpp::exception("Endpoint doesn't support secure connections.",websocketpp::error::ENDPOINT_UNSECURE);
|
||||
}
|
||||
|
||||
tcp::resolver::query query(location->get_host(),location->get_port_str());
|
||||
tcp::resolver::iterator iterator = m_resolver.resolve(query);
|
||||
|
||||
connection_ptr con = m_endpoint.create_connection();
|
||||
|
||||
if (!con) {
|
||||
throw websocketpp::exception("Endpoint is unavailable.",
|
||||
websocketpp::error::ENDPOINT_UNAVAILABLE);
|
||||
}
|
||||
|
||||
con->set_uri(location);
|
||||
|
||||
boost::asio::async_connect(
|
||||
|
||||
Reference in New Issue
Block a user