Re: Exception handling
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