Skip to content

Commit

Permalink
Merge pull request #251 from bitshares/update-asio-error
Browse files Browse the repository at this point in the history
Rethrow more asio operation cancellation exception as `fc::canceled_exception`
  • Loading branch information
abitmore committed Nov 18, 2023
2 parents 33cd59c + 91c1458 commit 3ea07ea
Showing 1 changed file with 34 additions and 5 deletions.
39 changes: 34 additions & 5 deletions src/asio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,23 @@ namespace fc {
if( !ec )
_completion_promise->set_value(bytes_transferred);
else if( ec == boost::asio::error::eof )
_completion_promise->set_exception( fc::exception_ptr( new fc::eof_exception( FC_LOG_MESSAGE( error, "${message} ", ("message", boost::system::system_error(ec).what())) ) ) );
{
_completion_promise->set_exception( std::make_shared<fc::eof_exception>(
FC_LOG_MESSAGE( error, "${message} ",
("message", boost::system::system_error(ec).what())) ) );
}
else if( ec == boost::asio::error::operation_aborted )
{
_completion_promise->set_exception( std::make_shared<fc::canceled_exception>(
FC_LOG_MESSAGE( error, "${message} ",
("message", boost::system::system_error(ec).what())) ) );
}
else
_completion_promise->set_exception( fc::exception_ptr( new fc::exception( FC_LOG_MESSAGE( error, "${message} ", ("message", boost::system::system_error(ec).what())) ) ) );
{
_completion_promise->set_exception( std::make_shared<fc::exception>(
FC_LOG_MESSAGE( error, "${message} ",
("message", boost::system::system_error(ec).what())) ) );
}
}
read_write_handler_with_buffer::read_write_handler_with_buffer(const promise<size_t>::ptr& completion_promise,
const std::shared_ptr<const char>& buffer) :
Expand All @@ -36,12 +50,27 @@ namespace fc {
if( !ec )
_completion_promise->set_value(bytes_transferred);
else if( ec == boost::asio::error::eof )
_completion_promise->set_exception( fc::exception_ptr( new fc::eof_exception( FC_LOG_MESSAGE( error, "${message} ", ("message", boost::system::system_error(ec).what())) ) ) );
{
_completion_promise->set_exception( std::make_shared<fc::eof_exception>(
FC_LOG_MESSAGE( error, "${message} ",
("message", boost::system::system_error(ec).what())) ) );
}
else if( ec == boost::asio::error::operation_aborted )
{
_completion_promise->set_exception( std::make_shared<fc::canceled_exception>(
FC_LOG_MESSAGE( error, "${message} ",
("message", boost::system::system_error(ec).what())) ) );
}
else
_completion_promise->set_exception( fc::exception_ptr( new fc::exception( FC_LOG_MESSAGE( error, "${message} ", ("message", boost::system::system_error(ec).what())) ) ) );
{
_completion_promise->set_exception( std::make_shared<fc::exception>(
FC_LOG_MESSAGE( error, "${message} ",
("message", boost::system::system_error(ec).what())) ) );
}
}

void read_write_handler_ec( promise<size_t>* p, boost::system::error_code* oec, const boost::system::error_code& ec, size_t bytes_transferred ) {
void read_write_handler_ec( promise<size_t>* p, boost::system::error_code* oec,
const boost::system::error_code& ec, size_t bytes_transferred ) {
p->set_value(bytes_transferred);
*oec = ec;
}
Expand Down

0 comments on commit 3ea07ea

Please sign in to comment.