[Issue 19602] Under some circumstances: throwing Error subclasses unwinds without invoking dtors

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Mar 17 07:45:34 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=19602

--- Comment #12 from Eyal <eyal at weka.io> ---
Walter, the question is: what benefits does the current approach have over a
much safer approach of having *only* "onError" callbacks that allow the user to
write some handling code in case of error before abort?

1) Even if the unwinding behavior is fixed to not unwind in case of errors,
using "catch" blocks to handle errors has very surprising semantics: it runs
code in broken contexts that have not run (scope(exit)s, finally's, destructors
all skipped).

2) Worse still: the program easily continues after catching Errors, even if it
is by accident -- in a completely corrupt state.

These would remain 2 huge gotchas to know about when working with try/catch.

Why keep them?

--


More information about the Digitalmars-d-bugs mailing list