• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSExceptionHandler question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: NSExceptionHandler question
      • From: Gideon King <email@hidden>
  • Prev by Date: Re: [Q] NSSplitView
  • Next by Date: Re: "Morphing" Sheets
  • Previous by thread: Re: [Q] NSSplitView
  • Next by thread: Re: NSExceptionHandler question
  • Index(es):
    • Date
    • Thread