• 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: Exception handling
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Exception handling


  • Subject: Re: Exception handling
  • From: Jens Alfke <email@hidden>
  • Date: Thu, 14 Jun 2018 10:06:16 -0700


> On Jun 13, 2018, at 7:53 PM, Quincey Morris
> <email@hidden> wrote:
>
> The situation with C++ exceptions is a bit different.

It's actually exactly the same, since at the runtime level Obj-C exceptions are
C++ exceptions.

> I really think you have exactly 2 error handling patterns:
> 1. Returning false/nil with an outError parameter for recoverable errors, and
> always testing the result at every level.
> 2. Throwing NSExceptions for unrecoverable errors, and letting the app crash
> immediately.

You can throw exceptions (C++ or NSException) in your own code, provided that
you catch and handle them before they unwind into system code*. (We use that
approach in the C++ core code of the Cocoa framework I work on.)

—Jens

* well, libc++ is fine of course since it's exception-aware.
_______________________________________________

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: 
 >Exception handling (From: Casey McDermott <email@hidden>)
 >Re: Exception handling (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: Exception handling
  • Next by Date: Re: Exception handling
  • Previous by thread: Re: Exception handling
  • Next by thread: Re: Exception handling
  • Index(es):
    • Date
    • Thread