• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Exceptions vs. pointers to error objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Exceptions vs. pointers to error objects


  • Subject: Re: Exceptions vs. pointers to error objects
  • From: "Stephen J. Butler" <email@hidden>
  • Date: Tue, 28 Oct 2008 04:18:39 -0500

On Tue, Oct 28, 2008 at 2:58 AM, Colin Cornaby <email@hidden> 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 (email@hidden)

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:

This email sent to email@hidden

References: 
 >Exceptions vs. pointers to error objects (From: Colin Cornaby <email@hidden>)

  • Prev by Date: Re: Exceptions vs. pointers to error objects
  • Next by Date: Code signing validation
  • Previous by thread: Re: Exceptions vs. pointers to error objects
  • Next by thread: Re: Exceptions vs. pointers to error objects
  • Index(es):
    • Date
    • Thread