The Proper Use of Exception Chaining: Caught between two conflicting usecases?
FeepingCreature
feepingcreature at gmail.com
Thu May 2 07:10:45 UTC 2019
On Saturday, 27 April 2019 at 07:08:50 UTC, Meta wrote:
> On Friday, 26 April 2019 at 08:32:58 UTC, FeepingCreature wrote:
>> Ping! This is a severe issue making debugging pointlessly hard.
>
> Case 2 is the intended use for chained exceptions. It's an
> answer to the question of "what happens if you throw an
> exception while another one is already in flight?" In the case
> of C++, the program is immediately aborted. In D's case, the
> second exception will be chained onto the first one.
Okay, but then that first of all contradicts the documentation at
https://dlang.org/library/object/throwable.next.html which
indicates that this feature is certainly confusing enough to be
misunderstandable, and second of all there's still very much a
call for being able to react to an exception by throwing an
exception of another type, without losing the first exception's
stack trace. Currently if we catch three types of exceptions that
happen somewhere in Phobos and rethrow them as some generic or
domain exception, the error will appear to come from the
exception handler. Does the error come from the exception
handler? No! The actual source of the error has been completely
obfuscated. This is bad!
More information about the Digitalmars-d
mailing list