Alternatives to exceptions for error handling

H. S. Teoh hsteoh at
Tue Nov 24 23:13:10 UTC 2020

On Tue, Nov 24, 2020 at 10:25:23PM +0000, IGotD- via Digitalmars-d wrote:
> There is one thing that I think must go in D and that is chaining
> exception, catching several exceptions. As it is today this requires
> memory allocation itself and I'm not sure that we can support
> exception chains without memory allocation.
> My experience is that looping through exceptions is extremely unusual
> and normally it is a first served approach that is used. Double,
> triple or more faults is often too difficult to deal with.

Yeah, chained exceptions are one of those things that look good on
paper, but in practice rarely used, yet if you look at druntime, there's
a bunch of very delicate and tricky (and ugly) code that's there just to
handle chained exceptions.  In retrospect, we should've just made it so
that throwing while another exception is in transit should just abort
the program, like C++ does (IIRC).

Now we probably can't replace that without breaking stuff. (Though
honestly, I doubt if anything would actually break besides the test


If blunt statements had a point, they wouldn't be blunt...

More information about the Digitalmars-d mailing list