Exception Safe Programming
Saaa
empty at needmail.com
Sun Feb 25 05:06:00 PST 2007
"renoX" <renosky at free.fr> wrote in message
news:errs2s$1pvc$1 at digitalmars.com...
> Saaa a écrit :
>> On the website there is the following example:
>>
>> Transaction abc()
>> {
>> Foo f;
>> Bar b;
>>
>> f = dofoo();
>> try
>> {
>> b = dobar();
>> return Transaction(f, b);
>> }
>> catch (Object o)
>> {
>> dofoo_undo(f);
>> throw o;
>> }
>> }
>>
>> When f=dofoo() is run and doesn't succeed I suspect that f hasn't changed
>> and dofoo has thrown an exception.
>> Because of the exception the try part isn't run, but the catch part is.
>> Did I understand this correctly?
>> The explanation of the try statement on the website is not the most
>> comprehensible one (^.^)
>
> That's probably because this is a counter-example, not an example really:
> more a (convincing) way to show that scope() is much better than try/catch
> for exception safe programming..
>
> renoX
I meant the try statement explanation on
http://www.digitalmars.com/d/statement.html#TryStatement
More information about the Digitalmars-d-learn
mailing list