Re: NSError: why returned directly?
Re: NSError: why returned directly?
- Subject: Re: NSError: why returned directly?
- From: Erik Buck <email@hidden>
- Date: Wed, 26 Apr 2006 07:07:01 -0700 (PDT)
My own opinion from many years of experience is that exceptions are abused vastly more often then they are used well.
We have all been reminded that goto is seldom a good idea. Well, an exception is a goto with a destination that can not be predicted by the author of the code that generates the exception (goto). Exceptions are the most pathological example of goto that is possible.
IMHO, exceptions should be reserved for this should never happen type situations. Frankly, I think exceptions should be reserved for situations where NSAssert() is used.
There is a difference between expected reasonable errors and exceptions. For example, trying to create a file on a full file system is an entirely predictable error. It is an expected error. Attempting to access an index beyond the end of an array is an expected error. Even though Foundation raises an NSRangeException or NSInvalidArgumentException, I dont think it should.
My experience with Ada, Java, C++, Eiffel, and Objective-C has been consistent that exceptions are virtually useless in all of these languages and to the extent framework designers used exceptions, the frameworks become harder to reuse.
In a sense, I think Apple is doing the right thing by reporting errors via method return value and providing a means to get more information about the error. I am ambivalent about error details being returned by reference.
However, unlike JOAR, I think Cocoa newbies need to be comfortable enough in C that parameters returned by reference are perfectly understandable.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden