[phobos] Exception chaining

Andrei Alexandrescu andrei at erdani.com
Thu Jan 13 11:11:43 PST 2011


Thanks for continuing to think of the best design for this, Don.

On 1/12/11 12:10 AM, Don Clugston wrote:
> How about this rule:
> ---
> If all collateral exceptions are derived from Exception, the 'boss' or
> Master Exception is the first exception thrown.
> Otherwise, the first Error (or Throwable non-Exception) is the boss.
> The exception, including all collateral exceptions, will be caught by
> the first handler who can catch the boss.
> ---

This is very sensible.

> Two issues:
> * If the boss is a collateral exception, we still need a way to find
> out what the first exception was. Maybe need to add a 'first' (or
> 'prev') member to Throwable?

Let's save that option for the future.

> * It is still possible to throw an Object which isn't derived from
> Throwable. Can we disallow this?

Yes please!

Also, as subsequently discussed, I, too, think it's reasonable to lose 
state if a non-Exception Throwable gets thrown.


Andrei


More information about the phobos mailing list