NSSetUncaughtExceptionHandler not working on Lion 10.7.3

561 Views Asked by At

The following simple code on the app's delegate on a new cocoa test project.

void onUncaughtException(NSException *exception){
    NSLog(@"Caught!!! %@", exception);
}

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    NSSetUncaughtExceptionHandler(&onUncaughtException);

    NSException *exception = [[NSException alloc]initWithName:@"exception" reason:@"exception reason here" userInfo:nil];
    @throw exception;
}

I only get single console log line with the exception name and reason, but onUncaughtException does not get called. The app continues to run without a problem.

What am I missing here? I tried this on debug and release builds with same results.

1

There are 1 best solutions below

1
On

I don't know all the ins and outs of it, but I suspect that NSApplication is intercepting it before it fails through to your handler.