Exception Safe Programming

Saaa empty at needmail.com
Sat Feb 24 15:52:47 PST 2007

That is exactly what I originally thought, but why then is that piece of 
code a example of how to ...
oh wait... if f=dofoo() fails, f is still unchanged and the correct thing to 
do is to exit the function through an exception.
never mind, but thanks :)

> Nope.  If "f = dofoo()" fails and an exception is thrown, that catch block 
> is not run, because "f = dofoo()" is outside the try block.  A catch block 
> is only run if an uncaught exception occurs in the try block right before 
> it.  Since "f = dofoo()" is not in a try block, any exception from it will 
> just be thrown out of abc().

More information about the Digitalmars-d-learn mailing list