What is this?

Sean Kelly sean at f4.ca
Mon Oct 22 07:22:02 PDT 2007


Lars Ivar Igesund wrote:
> bobef wrote:
> 
>> Hey guys,
>>
>> do you know what is this and could cause it?
>> "An exception was thrown while finalizing an instance of class whatever".
> 
> I believe it means an exception is thrown in a destructor or similar (and
> afaik a Tango feature).

This is exactly right.  Throwing an exception from a dtor constitutes a 
programming error and Tango attempts to discourage this by handling it 
in much the same way as an assertion failure.  The exception is wrapped 
in a FinalizeException before passing it up the stack.  This is one of 
the few (or perhaps the only) place in the Tango runtime where I decided 
to actually restrict legal programming behavior.  One reason for this is 
that currently, multiple in-flight exceptions will not terminate a D 
application--one will simply replace the other (this could be changed in 
the runtime as well but I haven't done so yet).  Another is that it's 
nearly impossible to write correct code if dtors are allowed to throw. 
C++ uses the no-throw spec for dtors in the STL for this reason, and I 
believe that "encouraging" the same behavior in user code is worthwhile.


Sean



More information about the Digitalmars-d mailing list