mirror of
https://github.com/allankoechke/websocketpp.git
synced 2026-12-02 09:54:59 +00:00
Preserve ASIO errors if possible in asio::endpoint too
This was already done in asio::xxx_socket::connection methods by using translate_ec() which allowed to preserve the error code when possible (i.e. when using Boost.ASIO with Boost.System or standalone ASIO with C++11 std::error_code), but errors also can happen in endpoint methods such as handle_connect(), where they were totally lost and replaced with a rather useless error::pass_through. With these changes, the real error codes are preserved and applications using the library can give more useful error messages if connection fails.
This commit is contained in:
@@ -423,7 +423,7 @@ public:
|
||||
m_acceptor->close();
|
||||
}
|
||||
log_err(log::elevel::info,"asio listen",bec);
|
||||
ec = make_error_code(error::pass_through);
|
||||
ec = socket_con_type::translate_ec(ec);
|
||||
} else {
|
||||
m_state = LISTENING;
|
||||
ec = lib::error_code();
|
||||
@@ -733,7 +733,7 @@ public:
|
||||
m_elog->write(log::elevel::info,
|
||||
"asio handle_timer error: "+ec.message());
|
||||
log_err(log::elevel::info,"asio handle_timer",ec);
|
||||
callback(make_error_code(error::pass_through));
|
||||
callback(socket_con_type::translate_ec(ec));
|
||||
}
|
||||
} else {
|
||||
callback(lib::error_code());
|
||||
@@ -818,7 +818,7 @@ protected:
|
||||
ret_ec = make_error_code(websocketpp::error::operation_canceled);
|
||||
} else {
|
||||
log_err(log::elevel::info,"asio handle_accept",asio_ec);
|
||||
ret_ec = make_error_code(error::pass_through);
|
||||
ret_ec = socket_con_type::translate_ec(asio_ec);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -961,7 +961,7 @@ protected:
|
||||
|
||||
if (ec) {
|
||||
log_err(log::elevel::info,"asio async_resolve",ec);
|
||||
callback(make_error_code(error::pass_through));
|
||||
callback(socket_con_type::translate_ec(ec));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1069,7 +1069,7 @@ protected:
|
||||
|
||||
if (ec) {
|
||||
log_err(log::elevel::info,"asio async_connect",ec);
|
||||
callback(make_error_code(error::pass_through));
|
||||
callback(socket_con_type::translate_ec(ec));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -261,6 +261,7 @@ protected:
|
||||
return lib::error_code();
|
||||
}
|
||||
|
||||
public:
|
||||
/// Translate any security policy specific information about an error code
|
||||
/**
|
||||
* Translate_ec takes an Asio error code and attempts to convert its value
|
||||
|
||||
@@ -333,6 +333,7 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
/// Translate any security policy specific information about an error code
|
||||
/**
|
||||
* Translate_ec takes an Asio error code and attempts to convert its value
|
||||
|
||||
Reference in New Issue
Block a user