FROM : Shaun Wexler
DATE : Tue Aug 08 05:46:33 2006
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.
DATE : Tue Aug 08 05:46:33 2006
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.






Cocoa mail archive

