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

# Type Alias: BeforeErrorHook

> **BeforeErrorHook** = (`error`) => [`ValifetchError`](../classes/ValifetchError.md) | `Promise`<[`ValifetchError`](../classes/ValifetchError.md)>

Defined in: [src/types/hooks.ts:61](https://github.com/haihv/valifetch/blob/285835d38a6676b98d2ee1a93e23166c6c834cb2/src/types/hooks.ts#L61)

Hook called just before a `ValifetchError` is thrown to the caller.
Must return the error to throw — the same instance (optionally mutated) or a
replacement `ValifetchError`.

## Parameters

### error

[`ValifetchError`](../classes/ValifetchError.md)

## Returns

[`ValifetchError`](../classes/ValifetchError.md) | `Promise`<[`ValifetchError`](../classes/ValifetchError.md)>
