|
Boost Users : |
Subject: Re: [Boost-users] Unable to catch exception using boost::asio
From: Alex Black (alex_at_[hidden])
Date: 2009-07-15 13:27:38
Thanks for the tip.
However, my destructors are empty in this case.
> -----Original Message-----
> From: boost-users-bounces_at_[hidden]
> [mailto:boost-users-bounces_at_[hidden]] On Behalf Of
> Emil Dotchevski
> Sent: Wednesday, July 15, 2009 1:21 PM
> To: boost-users_at_[hidden]
> Subject: Re: [Boost-users] Unable to catch exception using boost::asio
>
> On Wed, Jul 15, 2009 at 10:10 AM, Alex Black
> <alex_at_[hidden]> 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_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net