The Right Approach to Exceptions

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Feb 18 22:50:30 PST 2012


On 2/18/12 11:09 PM, Jim Hewes wrote:
> I think of exception handling as tied to contract programming. A
> function has a specific job that it's supposed to do. If for any reason
> it cannot do that job successfully, an exception should be thrown. That
> can include even bad parameters (although if you have bad parameters to
> internal functions I'd think that is a design bug and could be handled
> by asserts). Look at the .NET library; it seems to work this way. So I
> think the term 'exceptional situations' has been kind of useless.

I think there's a bit of a confusion there. In fact, I dedicated two 
distinct chapters to error handling and contract programming in TDPL in 
an attempt to dispel it.

Andrei



More information about the Digitalmars-d mailing list