---
url: /nestjs-odata/api/generated/classes/ODataParseError.md
---
# Class: ODataParseError

Defined in: [parser/errors.ts:16](https://github.com/cberd1509/nestjs-odata/blob/a42974292d62fe5da337a603d3b22d57c08cbf68/packages/core/src/parser/errors.ts#L16)

Thrown when the lexer or parser encounters malformed OData query syntax.

The `position` field indicates the character offset in the input string
where the error was detected. The `token` field (if available) holds
the token that triggered the error.

Note: position info is intentionally included — the input is the user's own
query string, not server-internal data, so there is no information disclosure risk.

## Extends

* `Error`

## Constructors

### Constructor

> **new ODataParseError**(`message`, `position`, `token?`, `queryContext?`): `ODataParseError`

Defined in: [parser/errors.ts:17](https://github.com/cberd1509/nestjs-odata/blob/a42974292d62fe5da337a603d3b22d57c08cbf68/packages/core/src/parser/errors.ts#L17)

#### Parameters

##### message

`string`

##### position

`number`

##### token?

`unknown` = `null`

##### queryContext?

`string`

#### Returns

`ODataParseError`

#### Overrides

`Error.constructor`

## Properties

### position

> `readonly` **position**: `number`

Defined in: [parser/errors.ts:19](https://github.com/cberd1509/nestjs-odata/blob/a42974292d62fe5da337a603d3b22d57c08cbf68/packages/core/src/parser/errors.ts#L19)

***

### queryContext?

> `readonly` `optional` **queryContext?**: `string`

Defined in: [parser/errors.ts:21](https://github.com/cberd1509/nestjs-odata/blob/a42974292d62fe5da337a603d3b22d57c08cbf68/packages/core/src/parser/errors.ts#L21)

***

### token

> `readonly` **token**: `unknown` = `null`

Defined in: [parser/errors.ts:20](https://github.com/cberd1509/nestjs-odata/blob/a42974292d62fe5da337a603d3b22d57c08cbf68/packages/core/src/parser/errors.ts#L20)

## Methods

### withContext()

> `static` **withContext**(`message`, `position`, `queryString`, `token?`): `ODataParseError`

Defined in: [parser/errors.ts:41](https://github.com/cberd1509/nestjs-odata/blob/a42974292d62fe5da337a603d3b22d57c08cbf68/packages/core/src/parser/errors.ts#L41)

Create an ODataParseError with a context snippet extracted from the query string.
Extracts ~20 characters before and after the error position for diagnostic context.

Per threat model T-12-05: context snippet shows only the user's own query input
(already known to them) — never includes stack traces or internal paths.

#### Parameters

##### message

`string`

Base error message

##### position

`number`

Character offset where the error was detected

##### queryString

`string`

The full query string for context extraction

##### token?

`unknown` = `null`

Optional token that triggered the error

#### Returns

`ODataParseError`
