On Tue, Oct 28, 2008 at 2:58 AM, Colin Cornaby <[EMAIL PROTECTED]> wrote: > I'm writing an API to communicate with a web service, and I was just > wondering what the thinking is on exceptions vs. functions returning an > NSError in some way. Basically I'm wondering what people's opinions are on a > function throwing an exception on failure, vs returning an NSError object. > > Perhaps there is already a policy on when each is to be used. If so, please > enlighten me. :)
For me there's two things to consider: 1) Without garbage collection, it's really hard to get exceptions to work properly with no memory leaks. 2) What paradigm does the language and API advocate? It's better, I think, to stick with one model rather than trying to mix. Imagine code that throws an exception, only to catch it and turn it into a returned error code, which then gets thrown later as an exception... drives me nuts. So with Obj-C I always use NSError. I like exceptions better, but the convention is to do it the other way. And that makes thrown exceptions more trouble than they're worth. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]