The Right Approach to Exceptions
SeeWebsiteForEmail at erdani.org
Mon Feb 20 13:23:34 PST 2012
On 2/20/12 3:14 PM, deadalnix wrote:
> Le 20/02/2012 22:05, Andrei Alexandrescu a écrit :
>> On 2/20/12 2:31 PM, Juan Manuel Cabo wrote:
>>>> Sure. Again, this is not advocating replacement of exception
>>>> hierarchies with tables!
>>> I think that the case of rethrowing an exception with added detail is
>>> the worst
>>> enemy of clean Exception hierarchies.
>>> The idea of Variant[string] remedies that case without creating a new
>>> class just for the added fields. If that case is solved, then the
>>> tipical need
>>> for creating new exception types that don't really aid selecting them
>>> catching and recovery is solved too.
>> Good point. One thing somewhat particular to D, you can always throw a
>> new exception linked to the current one.
> And this is great design.
I'm not so sure. It's more like an incompetent design by someone who
obviously knew nothing about exceptions.
> We should continue in that direction.
That has its own disadvantages, particularly the proliferation of types
simply to embody state, but it does work.
More information about the Digitalmars-d