[phobos] Exception chaining

Andrei Alexandrescu andrei at erdani.com
Tue Jan 11 15:53:55 PST 2011


On 1/11/11 12:44 PM, Lars Tandle Kyllingstad wrote:
> I think this is a good rule.  As you say, it is simple and easy to
> understand, and it ensures no critical exceptions are "lost" somewhere
> in a chain.  I would be very dissatisfied if my program throws an Error
> and it is caught (indirectly) by a catch(FileException) clause.

But that's not the alternative. There are several possible alternatives, 
one of which being that everything is just like until now. That _is_ the 
simplest almost by definition. We can discuss whether we can improve on 
that decision, but it is the simplest baseline.

I agree that throwing an Error brings a serious issue to the table. But 
throwing a DatabaseException while a FileException is already unwinding 
the stack should not transform what's happening. At the end of the day, 
the FileException was there "first".


Andrei


More information about the phobos mailing list