I have many different threads (boost::thread_pool) to a boost::asio::io_service. The io_service will call a function which will trigger async_read, which will trigger yet another async_read, from which many functions might be called. This is all done within two classes: threads spawn from a Server class, and async_read is called from a Client class.
Provided I throw from those functions called by async_read (from the Client class), who will get to catch the exception? Server? if so, is there any way to disregard the error and resume regular execution?.
Did you read this part of the Boost.Asio manual?
Summary:
“If an exception is thrown from a handler, the exception is allowed to propagate through the throwing thread’s invocation of run(), run_one(), poll() or poll_one(). No other threads that are calling any of these functions are affected. It is then the responsibility of the application to catch the exception.”
So it depends on where you have your
catchstatement.UPDATE
The generic way that exceptions work is that upon an error the function creating the error will
throwan exception. Any calling function will have totrythe worker function it calls, andcatchthe exception to resolve the error. Optionally, you could re-throw the caught exception (or any other exception) to any calling functions higher up the chain.