Exception Safe Programming
Frits van Bommel
fvbommel at REMwOVExCAPSs.nl
Sun Feb 25 05:52:36 PST 2007
Saaa wrote:
> "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;
>>> }
>>> }
[snip]
>> 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..
>
> I meant the try statement explanation on
> http://www.digitalmars.com/d/statement.html#TryStatement
The only example I see there is:
---
int main()
{
try
{
try
{
throw new Exception("first");
}
finally
{
printf("finally\n");
throw new Exception("second");
}
}
catch(Exception e)
{
printf("catch %.*s\n", e.msg);
}
printf("done\n");
return 0;
}
---
(printf? The horror... :( )
More information about the Digitalmars-d-learn
mailing list