NSExceptionHandler question
NSExceptionHandler question
- Subject: NSExceptionHandler question
- From: Mike Laster <email@hidden>
- Date: Wed, 10 Jul 2002 12:59:17 -0400
How do I get the backtrace capabiltiy of NSExceptionHandler yet still be
able to set my own uncaught exception handler?
Here is some example code:
#import <Foundation/Foundation.h>
#import <ExceptionHandling/NSExceptionHandler.h>
void _uncaughtExceptionHandler(NSException *e)
{
NSLog(@"Handle uncaught exception here: %@ (%@)", e, [e userInfo]);
}
int main (int argc, const char *argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSSetUncaughtExceptionHandler((NSUncaughtExceptionHandler
*)_uncaughtExceptionHandler);
[[NSExceptionHandler defaultExceptionHandler] setExceptionHandlingMask:
NSHandleUncaughtExceptionMask|
NSHandleUncaughtSystemExceptionMask|
NSHandleUncaughtRuntimeErrorMask|
NSHandleTopLevelExceptionMask|
NSHandleOtherExceptionMask
];
// insert your code here
NS_DURING
[NSException raise:NSGenericException format:@"Test Exception"];
NS_HANDLER
NSLog(@"localException: %@: %@", localException, [localException
userInfo]);
NS_ENDHANDLER
[NSException raise:NSGenericException format:@"Test Uncaught
Exception"];
[pool release];
exit(0); // insure the process exit status is 0
return 0; // ...and make main fit the ANSI spec.
}
The caught exception works fine, it has backtrace info in it like I want.
However the uncaught exception doesn't have one. What do I need to do to
get a backtrace in EVERY exception, caught our uncaught?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.