---
title: BrexError
editUrl: false
head: []
template: doc
prev: false
next: false
sidebar:
  hidden: false
  attrs: {}
pagefind: true
draft: false
---

Defined in: [src/core/error.ts:2](https://github.com/slingshot/brex/blob/9dff46b5d5637a0dd072bca56d02d8a0f4425312/src/core/error.ts#L2)

Error thrown for any non-2xx Brex API response.

## Extends

- `Error`

## Constructors

### Constructor

> **new BrexError**(`args`): `BrexError`

Defined in: [src/core/error.ts:14](https://github.com/slingshot/brex/blob/9dff46b5d5637a0dd072bca56d02d8a0f4425312/src/core/error.ts#L14)

#### Parameters

##### args

###### body

`unknown`

###### headers

`Headers`

###### method

`string`

###### status

`number`

###### url

`string`

#### Returns

`BrexError`

#### Overrides

`Error.constructor`

## Properties

### body

> `readonly` **body**: `unknown`

Defined in: [src/core/error.ts:8](https://github.com/slingshot/brex/blob/9dff46b5d5637a0dd072bca56d02d8a0f4425312/src/core/error.ts#L8)

Parsed JSON error body when the response was JSON, otherwise the raw text.

***

### cause?

> `optional` **cause?**: `unknown`

Defined in: docs/node\_modules/typescript/lib/lib.es2022.error.d.ts:26

#### Inherited from

`Error.cause`

***

### headers

> `readonly` **headers**: `Headers`

Defined in: [src/core/error.ts:10](https://github.com/slingshot/brex/blob/9dff46b5d5637a0dd072bca56d02d8a0f4425312/src/core/error.ts#L10)

Full response headers, as an escape hatch.

***

### message

> **message**: `string`

Defined in: docs/node\_modules/typescript/lib/lib.es5.d.ts:1077

#### Inherited from

`Error.message`

***

### method

> `readonly` **method**: `string`

Defined in: [src/core/error.ts:11](https://github.com/slingshot/brex/blob/9dff46b5d5637a0dd072bca56d02d8a0f4425312/src/core/error.ts#L11)

***

### name

> **name**: `string`

Defined in: docs/node\_modules/typescript/lib/lib.es5.d.ts:1076

#### Inherited from

`Error.name`

***

### requestId

> `readonly` **requestId**: `string` \| `undefined`

Defined in: [src/core/error.ts:6](https://github.com/slingshot/brex/blob/9dff46b5d5637a0dd072bca56d02d8a0f4425312/src/core/error.ts#L6)

Brex request id (from the `x-request-id` response header), if present.

***

### stack?

> `optional` **stack?**: `string`

Defined in: docs/node\_modules/typescript/lib/lib.es5.d.ts:1078

#### Inherited from

`Error.stack`

***

### status

> `readonly` **status**: `number`

Defined in: [src/core/error.ts:4](https://github.com/slingshot/brex/blob/9dff46b5d5637a0dd072bca56d02d8a0f4425312/src/core/error.ts#L4)

HTTP status code.

***

### url

> `readonly` **url**: `string`

Defined in: [src/core/error.ts:12](https://github.com/slingshot/brex/blob/9dff46b5d5637a0dd072bca56d02d8a0f4425312/src/core/error.ts#L12)