Detecting exception unwinding
Ola Fosheim Grøstad via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Feb 5 00:16:05 PST 2016
On Friday, 5 February 2016 at 07:31:24 UTC, cy wrote:
> I think you might be talking about two very different concepts
> here. Unwinding only happens within the context of a certain
> scope.
The object itself is the scope (RAII). If you can test for
"uncaught_exceptions" you can implement the equivalent of
scope(failure/success) etc within destructors.
So you basically should be able to do:
{
Database db ...;
for(...){
db.Transaction t = db.new_transaction(....)
// transaction t is closed here by destructor
// but should not commit if exception is unwinding
}
// db is closed here but should log different information for
exceptions
}
More information about the Digitalmars-d-learn
mailing list