Re: Crashing on all relevant exceptions
Re: Crashing on all relevant exceptions
- Subject: Re: Crashing on all relevant exceptions
- From: Aaron Jacobs <email@hidden>
- Date: Mon, 7 Aug 2006 19:34:21 -0700
As Nick noted, that only works on secondary threads, because of
NSApplication's handler. But even if it works on the main thread,
the way I want to "handle" the exception is by not handling it at
all, but rather having the application crash as if the exception was
not caught.
This will correctly cause the program to die if an exception is
raised, even if it happens during the processing of an event.
However, it causes the program to just quit with an exit status of
zero, which doesn't indicate to the system that it has crashed, so
e.g. the crash reporter window doesn't come up.
If I uncomment the line that re-raises the exception, then the
program correctly crashes. However, the crash report indicates
that it happened at that line in the run method, rather than on
the line that initially raised the exception. I would rather have
a crash report giving a correct stack trace.
Does anyone know how to get around this problem?
I'm actually surprised that code even works as well as it does --
shouldn't NSApplication's own exception handler be nested deeper
than that and thus take priority? Maybe it doesn't install an
exception handler if there's already an existing one? Does anyone
know why this works?
static void MyUncaughtExceptionHandler(NSException *exception)
{
// handle the exception
}
int main(int argc, char *argv[])
{
NSSetUncaughtExceptionHandler(MyUncaughtExceptionHandler);
return NSApplicationMain(argc, (const char **)argv);
}
_______________________________________________
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