The RAII technique will be much more useful if you can detect whenever an exception is in flight in the destructor. An idea is to have multiple destructors that receives an exception argument, like:
~this(Exception e) { do_something(); }
~this(OtherException e) { do_otherthing(); }
that get called when the destructor was called during an unwind for a raised exception.
Other people suggest a simpler solution: a library call to tell if the code is executed when an exception is in fligh.Report this item for cleanup