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.

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at