need to emulate scope(failure) with struct destructor
piotrklos via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun May 28 13:06:42 PDT 2017
I need to perform an action, in multiple separate functions, if
scope exits with an exception. The trouble is I don't want to
litter my code with scope(failure) everywhere. I already create
an instance of a struct at each location, with the sole purpose
of doing things at the end of scope.
So my code looks like:
Ideally I would put the statement from scope(failure) in the
struct's destructor and delete the scope(failure) statements.
I would need something like c++'s std::uncaught_exceptions() to
check if an exception is in flight.
Is there something like this in D?
PS I think that we have here a more general problem, because
dlang is missing a feature for composition of scope(...)
More information about the Digitalmars-d-learn