• 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: Professional Error Handling
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Professional Error Handling


  • Subject: Re: Professional Error Handling
  • From: Kyle Sluder <email@hidden>
  • Date: Mon, 26 Oct 2009 13:16:11 -0700

On Mon, Oct 26, 2009 at 12:57 PM, Dick Bridges
<email@hidden> wrote:
> IIUC, http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Exceptions/Exceptions.html is available to everyone and is not under NDA. It's the "Introduction to Exception Programming Topics for Cocoa". As noted on this page, the first article is titled "Exceptions and the Cocoa Frameworks" and "...describes NSException objects and their general use with the Cocoa frameworks." The page also contains a reference to the related CoreRecipes sample code. The document applies to both iPhone OS and Mac OS X. (FWIW, I am believe that exception handling is also used *->within<-* some or all of the core frameworks.)

In fact, some frameworks are implemented in C++, and use exceptions in
a way more idiomatic in that language.

> When discussing the relative merits of exceptions and error codes, the distinction between "expected" and "unexpected" errors (i.e., exceptions) must be maintained. Apple's "Error Handling Programming Guide for Cocoa" does an excellent job of describing "...the recommended way to communicate *->expected<-* errors in Cocoa applications" (emphasis added).


Correct, which is why you don't want to use exceptions for things like
"File not Found", but rather for programmer mistakes like "Tried to
set string value of integer attribute."

> The original question from Squ Aire contained a reference to the option of returning nil. It may well be that I misunderstood, but I interpreted that as exception handling and not the communication of normal, expected errors.

It appears you have misunderstood.  The NSError paradigm involves
returning a sentinel value (most frequently NO and nil) and filling in
the outError parameter.  No exception is thrown in this case.

--Kyle Sluder
_______________________________________________

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: 
 >Professional Error Handling (From: Squ Aire <email@hidden>)
 >RE: Professional Error Handling (From: Squ Aire <email@hidden>)
 >RE: Professional Error Handling (From: Dick Bridges <email@hidden>)
 >Re: Professional Error Handling (From: Alastair Houghton <email@hidden>)
 >RE: Professional Error Handling (From: Dick Bridges <email@hidden>)

  • Prev by Date: RE: Professional Error Handling
  • Next by Date: Snow Leopard Address Book rejecting dragged vCards
  • Previous by thread: RE: Professional Error Handling
  • Next by thread: Re: Professional Error Handling
  • Index(es):
    • Date
    • Thread