• 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: Uncaught exceptions thrown by Cocoa documented anywhere?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Uncaught exceptions thrown by Cocoa documented anywhere?


  • Subject: Re: Uncaught exceptions thrown by Cocoa documented anywhere?
  • From: Jens Alfke <email@hidden>
  • Date: Wed, 13 Feb 2008 15:48:26 -0800


On 13 Feb '08, at 11:43 AM, Adam P Jenkins wrote:

Not consistently. Some methods are documented as throwing exceptions, and others aren't.

In general, IIRC, you can mostly assume that unless a object parameter is explicitly documented as accepting nil as a legal value, it doesn't allow nil. The docs also aren't generally going to talk about what exceptions are raised, rather about what things are valid or invalid.


I find Apple's documentation particularly bad in this regard, compared to say the documentation for the Java, Python, C, or C++ standard libraries, and other proprietary libraries like MFC or QT.

Cocoa's philosophy on exceptions is different than those. In most languages that have exceptions, exceptions are considered things that can legally happen in uncommon but valid situations: 'file not found', 'can't parse this string into a number', etc. So the exceptions a method can throw are part of its API, since exceptions are an alternate return value.


But the Cocoa architects basically dislike exceptions, and the Cocoa frameworks (with a very few exceptions) raise exceptions only to indicate *programmer errors*: passing an illegal value to a parameter, accessing an invalid array index, calling a nonexistent method, etc. (It's roughly like the distinction between checked and unchecked exceptions in Java.) So exceptions aren't part of the API, they're just a mechanism for code to bail out if something illegal happens.

I don't happen to agree with this philosophy (and have been involved in too many internal debates about it...) but that's the way it is.

—Jens_______________________________________________

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


  • Follow-Ups:
    • Re: Uncaught exceptions thrown by Cocoa documented anywhere?
      • From: Bill Bumgarner <email@hidden>
    • Re: Uncaught exceptions thrown by Cocoa documented anywhere?
      • From: Chris Suter <email@hidden>
References: 
 >Uncaught exceptions thrown by Cocoa documented anywhere? (From: James Hober <email@hidden>)
 >Re: Uncaught exceptions thrown by Cocoa documented anywhere? (From: Adam P Jenkins <email@hidden>)

  • Prev by Date: Re: Setting alignment of NSTextView programmatically
  • Next by Date: Re: ICal Alarm View
  • Previous by thread: Re: Uncaught exceptions thrown by Cocoa documented anywhere?
  • Next by thread: Re: Uncaught exceptions thrown by Cocoa documented anywhere?
  • Index(es):
    • Date
    • Thread