Hi and I’m working on handling exceptions in an app.
My exception handler code is as below.
In AppDelegate.h
@interface AppDelegate : NSObject <NSApplicationDelegate>
static void uncaughtExceptionhandler(NSException* exception);
In AppDelegate.m
@implementation AppDelegate
static void uncaughtExceptionhandler(NSException* exception) {
//log related information
}
-(void)applicationDidFinishLaunching:(NSNotification *)aNotification {
NSSetUncaughtExceptionHandler(&uncaughtExceptionhandler);
}
In order to test this handler, I raised an expection in my code.
In MyWindowController.m
- (void)testHandler {
@throw [NSException exceptionWithName:@"TestException" reason:@"TestOnly" userInfo:nil];
}
But noting was logged and it seemed uncaughtExceptionhandler function was not triggered.
I’m not sure if my exception handler code is right.