• 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
Re: Crashing on all relevant exceptions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Crashing on all relevant exceptions


  • Subject: Re: Crashing on all relevant exceptions
  • From: Shaun Wexler <email@hidden>
  • Date: Mon, 7 Aug 2006 20:46:33 -0700

On Aug 7, 2006, at 8:17 PM, Aaron Jacobs wrote:

After correcting the problem with the single = sign in the if statement, this compiles and runs fine. But it still has the same problem as the other solutions: the only way to preempt NSApplication's exception handler is to install my own, but if I do that, then the application does not crash when there is an exception.

Either I want some way for my handler to force the application to crash with the stack trace of when the exception was originally raised, or I want there to be no exception handler at all.

#include <RTFM> #import <Cocoa/Cocoa.h> #import <ExceptionHandling/NSExceptionHandler.h>

static void MyUncaughtExceptionHandler(NSException *exception)
{
NSLog(@"*** Uncaught exception: %@ %@ [%@]\n", [exception name], [exception reason],
[[exception userInfo] objectForKey:NSStackTraceKey]);
}


int main(int argc, char *argv[])
{
NSSetUncaughtExceptionHandler(MyUncaughtExceptionHandler);

[[NSExceptionHandler defaultExceptionHandler] setExceptionHandlingMask:
NSHandleUncaughtExceptionMask |
NSHandleUncaughtSystemExceptionMask |
NSHandleUncaughtRuntimeErrorMask |
NSHandleTopLevelExceptionMask |
NSHandleOtherExceptionMask];

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
Class appClass = NSClassFromString([infoDict objectForKey:@"NSPrincipalClass"]);
[NSBundle loadNibNamed:[infoDict objectForKey:@"NSMainNibFile"] owner:[appClass sharedApplication]];
[NSApp finishLaunching];
[pool release];

do {
@try {
[NSApp run];
}
@catch (NSException *exception) {
MyUncaughtExceptionHandler(exception);
}
} while ([NSApp isRunning]);

return 0;
}


--
Shaun Wexler
MacFOH
http://www.macfoh.com

Sarchasm \sar"chasm\, n. the void between the author of a satirical witticism and the recipient who just doesn't get it.


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Crashing on all relevant exceptions
      • From: Aaron Jacobs <email@hidden>
References: 
 >Crashing on all relevant exceptions (From: Aaron Jacobs <email@hidden>)
 >Re: Crashing on all relevant exceptions (From: Nick Zitzmann <email@hidden>)
 >Re: Crashing on all relevant exceptions (From: Aaron Jacobs <email@hidden>)
 >Re: Crashing on all relevant exceptions (From: Nick Zitzmann <email@hidden>)
 >Re: Crashing on all relevant exceptions (From: Aaron Jacobs <email@hidden>)
 >Re: Crashing on all relevant exceptions (From: Shaun Wexler <email@hidden>)
 >Re: Crashing on all relevant exceptions (From: Nick Zitzmann <email@hidden>)
 >Re: Crashing on all relevant exceptions (From: Shaun Wexler <email@hidden>)
 >Re: Crashing on all relevant exceptions (From: Aaron Jacobs <email@hidden>)

  • Prev by Date: ftp file busy?
  • Next by Date: Re: Crashing on all relevant exceptions
  • Previous by thread: Re: Crashing on all relevant exceptions
  • Next by thread: Re: Crashing on all relevant exceptions
  • Index(es):
    • Date
    • Thread