atom feed9 messages in com.omnigroup.macosx-devNSSetUncaughtExceptionHandler
FromSent OnAttachments
Paul R. SummermatterAug 28, 1999 6:39 am 
Ryan DingmanAug 28, 1999 1:27 pm 
Timothy J. WoodAug 28, 1999 3:54 pm 
Ryan DingmanAug 28, 1999 11:10 pm 
Paul R. SummermatterAug 29, 1999 10:42 am 
Paul R. SummermatterAug 29, 1999 3:17 pm 
Michelle L. BuckAug 29, 1999 5:06 pm 
Michelle L. BuckAug 29, 1999 5:15 pm 
Norbert HegerAug 31, 1999 1:17 am 
From:Timothy J. Wood (
Date:Aug 28, 1999 3:54:51 pm

From: "Paul R. Summermatter" <> [...]

.. but how do I declare and then set my own exception handler using the NSSetUncaughtException. I've tried the following which gives me a compiler warning that "passing arg 1 of 'NSSetUncaughtExceptionHandler' from incompatible pointer type", and then, at runtime, though I have stepped through the call to NSSetUncaughtExceptionHandler() in applicationDidFinishLaunching:, my function is never used:

From: Ryan Dingman <> [...]

NSSetUncaughtExceptionHandler needs the address of your function so your implementation of -applicationDidFinishLaunching should look like this.

- (void)applicationDidFinishLaunching:(NSNotification *)notification { NSSetUncaughtExceptionHandler(&LGSUncaughtExceptionHandler); }

Ryan has been getting into the wacky-weed or something... :)

You never need to take the address of functions -- you just pass them. You are most likely getting warning because your function is not of the required type. Your function is:

volatile void LGSUncaughtExceptionHandler(NSException *exception)

But NSException.h defines:

typedef void NSUncaughtExceptionHandler(NSException *exception);

Remove the 'volatile' and you should not get a warning. As to why your function is never called, its probably because you are misunderstanding what this handler does. I believe that this function is what is used if there is _NO_ wrapping NS_DURING block anywhere in the stack for the current thread.

If you are just using a simple AppKit program it will ensure that there is always a top-level exception handler. If you fork a thread, you have to establish your own top level handler, otherwise the uncaught handler will be used when an exception is raised in that thread.

If you want to do something special with exceptions that make their way up to AppKit's handler, you should subclass NSApplication and implement a -reportException: method.