---
url: /nestjs-odata/api/generated/type-aliases/ODataErrorMapper.md
---
# Type Alias: ODataErrorMapper

> **ODataErrorMapper** = (`exception`, `context`) => [`ODataErrorMapping`](../interfaces/ODataErrorMapping.md) | `undefined` | `null`

Defined in: [response/odata-error.ts:74](https://github.com/cberd1509/nestjs-odata/blob/a42974292d62fe5da337a603d3b22d57c08cbf68/packages/core/src/response/odata-error.ts#L74)

Maps any exception thrown while handling an OData request to the OData error to send.
Return `undefined` to fall back to the library's default mapping.

It runs for the routes declared with the OData route decorators (`@ODataGet`, `@ODataPost`,
…), for `$metadata` and for every failing operation of a `$batch` request. It must be
synchronous. If it throws, returns a Promise or returns an invalid mapping, a warning is
logged and the default mapping is used.

## Parameters

### exception

`unknown`

### context

[`ODataErrorMapperContext`](../interfaces/ODataErrorMapperContext.md)

## Returns

[`ODataErrorMapping`](../interfaces/ODataErrorMapping.md) | `undefined` | `null`
