Along those lines, here are some approaches we used on iOS to catch exceptions 
and to throw exceptions.

- (id)argument {
    if (!_argument) {
        @throw [NSException exceptionWithName:NSInternalInconsistencyException 
reason:@"Argument requested has yet to be captured." userInfo:nil];


      if (![HMACData rnc_isEqualInConsistentTime:self.inData]) {
        [self cleanupAndNotifyWithError:
         [NSError errorWithDomain:kRNCryptorErrorDomain
                             code:kRNCryptorHMACMismatch
                         userInfo:[NSDictionary dictionaryWithObject:@"HMAC 
Mismatch" /* DNL */
                                                              
forKey:NSLocalizedDescriptionKey]]];
          return;
      }

We also set NSSetUncaughtExceptionHandler declared in the appDelegate.

    NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);

#pragma mark -
#pragma mark Exception Handler

void uncaughtExceptionHandler(NSException *exception) {
    DLog(@"CRASH: %@", exception);
    DLog(@"Stack Trace: %@", [exception callStackSymbols]);
    // Internal error reporting
}
 

Hope this helps.
- Alex Zavatone

> On Jun 15, 2018, at 1:30 PM, Jens Alfke <j...@mooseyard.com> wrote:
> 
> 
> 
>> On Jun 14, 2018, at 5:58 PM, Quincey Morris 
>> <quinceymor...@rivergatesoftware.com> wrote:
>> 
>> as someone already mentioned, NSExceptions can’t successfully cross 
>> dylib/framework boundaries.
> 
> They can, actually; there is no problem with this at the ABI/runtime level.
> 
> I think what you mean is that most libraries/frameworks don't make guarantees 
> about properly handling exceptions thrown into them, i.e. from a call into 
> external code. Some C++ libraries do guarantee this (especially libc++), and 
> even without guarantees a typical C++ lib using RAII will be relatively safe, 
> but Objective-C code usually isn't written to be exception-safe, and C code 
> of course can't be.
> 
> —Jens
> _______________________________________________
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
> 
> This email sent to z...@mac.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to