The Right Approach to Exceptions

Andrei Alexandrescu SeeWebsiteForEmail at
Sun Feb 19 08:00:13 PST 2012

On 2/19/12 3:17 AM, Jonathan M Davis wrote:
> "As much information as possible" is way more than a transient property. If my
> code is going to retry or do something else or give up, it needs enough
> information to know what went wrong, not just whether the function which was
> called think it might work on a second try.
> Having an exception hierarchy provides some of that information simply with
> the types, and makes it easier to organize code based on what went wrong (e.g.
> separate catch blocks for each type of exception). And having that hierarchy
> also means that the derived types can have additional information beyond their
> type which could be useful but is specific to that problem and so wouldn't make
> sense on a general exception type.
> I really don't see what transient buys you in comparison to that.

A notion of transiency planted fundamentally in all exceptions allows 
one to act on it regardless of origin and hierarchy.


More information about the Digitalmars-d mailing list