
Hi Giovanni, --- "Giovanni P. Deretta" <gpderetta@gmail.com> wrote: <snip>
I've done exactly that in my network library (although it does support only synchronous behaviour). An optional error handler functor is passed to every functions that can generate an error. If no handler is passed a default handler is used that converts errors in exceptions. It works quite well. The user need to explicitly check for errors only if it wants to, else exceptions are used.
In fact asio uses what sounds like exactly the same approach for the synchronous functions. E.g. sock.write_some(bufs, asio::throw_error()); sock.write_some(bufs, asio::ignore_error()); asio::error error; sock.write_some(bufs, asio::assign_error(error)); sock.write_some(bufs, custom_error_handler); The default is also to convert the error into an exception. Cheers, Chris