Lets say for example I have a boost::asio::steady_timer timer
that I want to async wait on with boost::asio::steady_timer::async_wait
. In the old way I get errors as code parameter in my completion handler i.e. my lambda like
timer.async_wait([](const auto &boost_error) {
//check boost_error
});
With Co routines I am able to co_await
when using boost::asio::use_awaitable
as
co_await timer.async_wait(boost::asio::use_awaitable);
However the error handling has changed: In order to catch errors, like an cancel
ed timer, I have to wrap my co_await in a try/catch block.
Can I get boost to let me await on the async operation but giving me the error as a code, like
std::variant<void, error_code> = co_await timer.async_wait(boost::asio::use_awaitable);
?