• 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: "Adam R. Maxwell" <email@hidden>
  • Date: Fri, 15 Feb 2008 09:30:54 -0800

On Friday, February 15, 2008, at 09:18AM, "John Stiles" <email@hidden> wrote:
>Bill Bumgarner wrote:
>> On Feb 15, 2008, at 8:49 AM, Chris Ryland wrote:
>>> What if you're using GC (and wrapping non-Cocoa things with
>>> *MakeCollectable())--is it then safe to use exceptions through Cocoa
>>> frames?
>>
>> No;   it isn't limited to memory management issues.  There may be any
>> number of bits of teardown / cleanup code that will be skipped as the
>> exception passes over it.
>That's always been my problem with exception handling in general. When
>everything is working fine, it's great and makes code look simpler. When
>a problem actually occurs, I think understanding the flow of control is
>extremely difficult if you aren't intimately familiar with the code base.

As a concrete example, this bit us when converting an app to use the NSDocument saving methods in 10.4 that use NSError** parameters.  In 10.3 and earlier, we had been throwing exceptions and using them to bubble an informative error back up to the user for a lower-level save problem (string encoding conversion), but exceptions and NSError** do not mix.

It's really easy to throw an exception that keeps you from initializing an error pointer properly, and when you or AppKit try an use a garbage error, bad things happen...most of the time.  The most stable solution was to eliminate exceptions and use NSErrors; this led to more code (NSErrors are annoyingly messy to create), but with far fewer problems.

--
adam
_______________________________________________

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: 
 >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>)
 >Re: Uncaught exceptions thrown by Cocoa documented anywhere? (From: Jens Alfke <email@hidden>)
 >Re: Uncaught exceptions thrown by Cocoa documented anywhere? (From: Bill Bumgarner <email@hidden>)
 >Re: Uncaught exceptions thrown by Cocoa documented anywhere? (From: Chris Ryland <email@hidden>)
 >Re: Uncaught exceptions thrown by Cocoa documented anywhere? (From: Bill Bumgarner <email@hidden>)
 >Re: Uncaught exceptions thrown by Cocoa documented anywhere? (From: John Stiles <email@hidden>)

  • Prev by Date: Re: In-loop releasing of objects does not free memory?
  • Next by Date: Re: KVC and KVO for arrays
  • 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