The Right Approach to Exceptions

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Feb 18 18:28:32 PST 2012


On 2/18/12 6:36 PM, H. S. Teoh wrote:
> Note also, that an elaborated exception hierarchy lets you attach
> additional specific information that might be useful in error recovery.
> For example, FileException may have a field containing the filename that
> caused the error, so that if the program is processing a list of
> filenames, it knows which one went wrong. You would not want such
> information in Exception, because it only applies to FileException's.

If an exception adds state and/or interface to the table, I agree that 
may justify its existence as a distinct type.

Andrei


More information about the Digitalmars-d mailing list