Important: The information in this document is obsolete and should not be used for new development.
MyExceptionHandler
An exception handler should have this prototype:
OSStatus MyExceptionHandler (ExceptionInformation *theException);
- theException
- The address of an exception information block describing the exception that triggered the exception handler.
DESCRIPTION
You pass the address of yourMyExceptionHandler
routine to the Exception Manager'sInstallExceptionHandler
function. The Exception Manager subsequently calls your exception handler for all exceptions that arise in your application's context that are not intercepted by the Operating System.Your exception handler can take whatever steps are necessary to handle the exception or to correct the error or special condition that caused the exception. If your handler is successful, it should return the
noErr
result code. If you pass backnoErr
, the Exception Manager restores the machine state to the state contained in the exception information record pointed to by thetheException
parameter and resumes execution.If your handler is not able to handle the exception, it should return some other result code. However, if your handler returns a nonzero result code, the current application is likely to be terminated by the Process Manager.
An exception handler uses the same stack that is active at the time an exception occurs. To ensure that no stack data is destroyed, the Exception Manager advances the stack pointer prior to calling the exception handler.
SPECIAL CONSIDERATIONS
An exception handler must follow the same general guidelines as other kinds of asynchronous software. For instance, it cannot cause memory to be purged or compacted, and it should not use any handles that are not locked. See Inside Macintosh: Processes for a description of the restrictions applying to interrupt tasks and other asynchronous software.An exception handler must be reentrant if it can itself generate exceptions.
SEE ALSO
See "Writing an Exception Handler" on page 4-7 for more information about writing an exception handler.