Boost logo

Boost Users :

Subject: Re: [Boost-users] Exception: adding diagnostic information from a dtor?
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2011-06-15 22:13:19


On Wed, Jun 15, 2011 at 7:02 PM, alfC <alfredo.correa_at_[hidden]> wrote:
> sorry if I don't get the question right. can't you just do this?
>
>>     } catch( boost::exception & e ) {
>>         throw (e << boost::errinfo_file_name(file_name) );
>>     }

Unless there is a bug in Boost Exception, the above should give you a
compile error. By design, to avoid slicing, the boost::exception type
is an abstract base type and you can not throw it. The correct syntax
would be:

e << boost::errinfno_file_name(file_name);
throw; //OK, throws the *original* exception object.

Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode


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