# Function: addOnError() (/pixi-vn/index/namespaces/Game/functions/addOnError)



\> **addOnError**(`value`): () => `void`

Defined in: [src/index.ts:359](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/index.ts#L359)

Register an error handler. Multiple handlers can be registered; they
will be executed in registration order.

You can also check if the error is an instance of [PixiError](/pixi-vn/index/classes/PixiError) to handle specific errors related to Pixi’VN.

## Parameters [#parameters]

### value [#value]

[`OnErrorHandler`](/pixi-vn/index/type-aliases/OnErrorHandler)

## Returns [#returns]

() => `void`

## Example [#example]

```ts
// Register a synchronous error handler
Game.addOnError((error, props) => {
   props.notify("An error occurred")
   // send a notification to GlitchTip, Sentry, etc...
})

// Register an error handler for Pixi’VN specific errors
Game.addOnError((error, { notify }) => {
    if (error instanceof PixiError) {
        // ...
    }
});

// Register an asynchronous error handler
Game.addOnError(async (error, props) => {
   await logErrorToServer(error)
   props.notify("An error occurred")
})

// Register an error handler with step restoration/rollback
Game.addOnError(async (error, props) => {
   // Restore the game state to the previous step
   await stepHistory.back(props)
   props.notify("An error occurred, returning to previous step")
})
```
