Thanks for the tip. However, my destructors are empty in this case.
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Emil Dotchevski Sent: Wednesday, July 15, 2009 1:21 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] Unable to catch exception using boost::asio
On Wed, Jul 15, 2009 at 10:10 AM, Alex Black
wrote: You mentioned never throwing exceptions in destructors - sounds like good advice, thx. Two points though: 1. If an exception is thrown in a destructor can it not be caught with a try catch( ... )?
If a destructor calls functions that may throw, it should use catch(...) and not let exceptions propagate out of the destructor itself. However, when writing or sending data, the user may want to know that the operation has completed successfully. Typically, you'd provide a separate flush function for that use case, which you'd then call in the destructor, as in:
foo_sender::~foo_sender() { try { flush(); } catch(...) { } }
Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users