# OS_SetUserExceptionHandler

## C Specification

      #include <nitro/os.h>

      void OS_SetUserExceptionHandler(
                         OSExceptionHandler  handler
                         void*               arg );

## Description

This function sets the user function that will be called when an exception is generated.

The user function is of the type `OSExceptionHandler`. It is defined by
`typedef void (*OSExceptionHandler)( u32, void* );`

When calling the user function, the first argument is a pointer address (`u32`) to the structure the holds the context for the generated exception. For the second argument, `arg`, which is specified by the second argument of `OS_SetUserExceptionHandler()`, is passed as-is.

Additionally, the following are stored at the destination specified by the first argument, in addition to the `OSContext` that is specified by `OS_InitContext()`, etc: coprocessor state (`u32`), SPSR (`u32`. Non-SPSR modes not decided), reset or exception (`u32`. 0 = exception, non-0 = reset).

## Arguments

`handler` | Function to be called when an exception is generated
`arg` | Argument used when calling the user function

## Return Values

None

## See Also

`OS_InitException, OS_InitContext`

## Revision History

02/19/2004 Initial version