Re: Crashing on all relevant exceptions
Re: Crashing on all relevant exceptions
- Subject: Re: Crashing on all relevant exceptions
- From: Shaun Wexler <email@hidden>
- Date: Mon, 7 Aug 2006 17:28:27 -0700
On Aug 7, 2006, at 1:48 PM, Aaron Jacobs wrote:
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);
}
As a side note, CFRunLoop/NSRunLoop leaks a 16-byte memory allocation
for every uncaught exception within its callouts. <rdar://problem/
4670839>
--
Shaun Wexler
MacFOH
http://www.macfoh.com
Good code doesn't throw exceptions.
_______________________________________________
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