---
url: >-
  https://haihv.github.io/valifetch/api/index/type-aliases/ValifetchErrorOptions.md
---

# Type Alias: ValifetchErrorOptions

> **ValifetchErrorOptions** = `object`

Defined in: [src/errors/ValifetchError.ts:19](https://github.com/haihv/valifetch/blob/285835d38a6676b98d2ee1a93e23166c6c834cb2/src/errors/ValifetchError.ts#L19)

Options for creating a ValifetchError

## Properties

### cause?

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

Defined in: [src/errors/ValifetchError.ts:35](https://github.com/haihv/valifetch/blob/285835d38a6676b98d2ee1a93e23166c6c834cb2/src/errors/ValifetchError.ts#L35)

Original error cause. Typed as `unknown` to match the standard
`Error.cause`, so any thrown value (not just an `Error`) can be passed
through without wrapping.

***

### code

> **code**: [`ErrorCode`](ErrorCode.md)

Defined in: [src/errors/ValifetchError.ts:23](https://github.com/haihv/valifetch/blob/285835d38a6676b98d2ee1a93e23166c6c834cb2/src/errors/ValifetchError.ts#L23)

Error code for pattern matching

***

### message

> **message**: `string`

Defined in: [src/errors/ValifetchError.ts:21](https://github.com/haihv/valifetch/blob/285835d38a6676b98d2ee1a93e23166c6c834cb2/src/errors/ValifetchError.ts#L21)

Error message

***

### request?

> `optional` **request?**: `Request`

Defined in: [src/errors/ValifetchError.ts:25](https://github.com/haihv/valifetch/blob/285835d38a6676b98d2ee1a93e23166c6c834cb2/src/errors/ValifetchError.ts#L25)

HTTP request that caused the error

***

### response?

> `optional` **response?**: `Response`

Defined in: [src/errors/ValifetchError.ts:27](https://github.com/haihv/valifetch/blob/285835d38a6676b98d2ee1a93e23166c6c834cb2/src/errors/ValifetchError.ts#L27)

HTTP response (if received)

***

### responseBody?

> `optional` **responseBody?**: `unknown`

Defined in: [src/errors/ValifetchError.ts:42](https://github.com/haihv/valifetch/blob/285835d38a6676b98d2ee1a93e23166c6c834cb2/src/errors/ValifetchError.ts#L42)

Parsed response body on `HTTP_ERROR` (JSON-parsed object/array, or plain
text when the body is not valid JSON) and raw text on `PARSE_ERROR`
(the response body that failed to parse as JSON). `undefined` when the
body could not be read at all.

***

### validation?

> `optional` **validation?**: [`ValidationErrorInfo`](ValidationErrorInfo.md)

Defined in: [src/errors/ValifetchError.ts:29](https://github.com/haihv/valifetch/blob/285835d38a6676b98d2ee1a93e23166c6c834cb2/src/errors/ValifetchError.ts#L29)

Validation error details (if validation failed)
