Skip to content

Commit 88de392

Browse files
authored
Merge pull request zaphoyd#652 from vadz/preserve-asio-errors
Preserve ASIO errors if possible
2 parents e79e0d1 + 81ef065 commit 88de392

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

websocketpp/transport/asio/endpoint.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ class endpoint : public config::socket_type {
442442
m_acceptor->close();
443443
}
444444
log_err(log::elevel::info,"asio listen",bec);
445-
ec = make_error_code(error::pass_through);
445+
ec = socket_con_type::translate_ec(ec);
446446
} else {
447447
m_state = LISTENING;
448448
ec = lib::error_code();
@@ -752,7 +752,7 @@ class endpoint : public config::socket_type {
752752
m_elog->write(log::elevel::info,
753753
"asio handle_timer error: "+ec.message());
754754
log_err(log::elevel::info,"asio handle_timer",ec);
755-
callback(make_error_code(error::pass_through));
755+
callback(socket_con_type::translate_ec(ec));
756756
}
757757
} else {
758758
callback(lib::error_code());
@@ -837,7 +837,7 @@ class endpoint : public config::socket_type {
837837
ret_ec = make_error_code(websocketpp::error::operation_canceled);
838838
} else {
839839
log_err(log::elevel::info,"asio handle_accept",asio_ec);
840-
ret_ec = make_error_code(error::pass_through);
840+
ret_ec = socket_con_type::translate_ec(asio_ec);
841841
}
842842
}
843843

@@ -980,7 +980,7 @@ class endpoint : public config::socket_type {
980980

981981
if (ec) {
982982
log_err(log::elevel::info,"asio async_resolve",ec);
983-
callback(make_error_code(error::pass_through));
983+
callback(socket_con_type::translate_ec(ec));
984984
return;
985985
}
986986

@@ -1088,7 +1088,7 @@ class endpoint : public config::socket_type {
10881088

10891089
if (ec) {
10901090
log_err(log::elevel::info,"asio async_connect",ec);
1091-
callback(make_error_code(error::pass_through));
1091+
callback(socket_con_type::translate_ec(ec));
10921092
return;
10931093
}
10941094

websocketpp/transport/asio/security/none.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ class connection : public lib::enable_shared_from_this<connection> {
261261
return lib::error_code();
262262
}
263263

264+
public:
264265
/// Translate any security policy specific information about an error code
265266
/**
266267
* Translate_ec takes an Asio error code and attempts to convert its value
@@ -280,11 +281,13 @@ class connection : public lib::enable_shared_from_this<connection> {
280281
* @return The translated error code
281282
*/
282283
template <typename ErrorCodeType>
284+
static
283285
lib::error_code translate_ec(ErrorCodeType) {
284286
// We don't know any more information about this error so pass through
285287
return make_error_code(transport::error::pass_through);
286288
}
287-
289+
290+
static
288291
/// Overload of translate_ec to catch cases where lib::error_code is the
289292
/// same type as lib::asio::error_code
290293
lib::error_code translate_ec(lib::error_code ec) {

websocketpp/transport/asio/security/tls.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ class connection : public lib::enable_shared_from_this<connection> {
333333
}
334334
}
335335

336+
public:
336337
/// Translate any security policy specific information about an error code
337338
/**
338339
* Translate_ec takes an Asio error code and attempts to convert its value
@@ -353,6 +354,7 @@ class connection : public lib::enable_shared_from_this<connection> {
353354
* @return The translated error code
354355
*/
355356
template <typename ErrorCodeType>
357+
static
356358
lib::error_code translate_ec(ErrorCodeType ec) {
357359
if (ec.category() == lib::asio::error::get_ssl_category()) {
358360
// We know it is a TLS related error, but otherwise don't know more.
@@ -364,7 +366,8 @@ class connection : public lib::enable_shared_from_this<connection> {
364366
return make_error_code(transport::error::pass_through);
365367
}
366368
}
367-
369+
370+
static
368371
/// Overload of translate_ec to catch cases where lib::error_code is the
369372
/// same type as lib::asio::error_code
370373
lib::error_code translate_ec(lib::error_code ec) {

0 commit comments

Comments
 (0)