ideal syntax would be something along those lines:
try{...}
catch(SomeThrowableType e, &callback_before_unwinding){...}
with callback_before_unwinding of type 'void function(Throwable t)'
The semantics of which is:
if 'e' is about to be caught in this particular catch block, call callback_before_unwinding(e) _before_ unwinding stack and entering catch block.
Advantages are:
* it allows one to, for example, attach a debugger before stack unwinds and entering this catch block
* the debugger is only attached at that point, hence not making the regular program slower
* it doesn't affect other catch blocks nor does it affect how exceptions/errors are thrown
* it could even allow one to make speed up exception handling, by computing backtrace _only_ inside this callback_before_unwinding, so that usual exceptions (std.conv conversions etc) can be caught without any backtrace inside the main program while unusual unintended exceptions would be caught at the root and show proper stack trace.
This saves a lot of time when debugging issues, at _zero_ cost in performance.
Does libunwind allow that? Otherwise could it be adapted to do that?