---
title: "@vltpkg/output: error — vlt docs"
description: "Documentation for the vlt client and the vlt registry."
url: "https://docs.vlt.io/client/api-reference/output/error"
image: "https://docs.vlt.io/og/client/api-reference/output/error"
lang: "en"
---

# error

## Type Aliases

### ErrorCause

```ts
type ErrorCause = Record<string, unknown> & object;
```

Defined in: error.ts:3

#### Type declaration

| Name     | Type                                                                                |
| -------- | ----------------------------------------------------------------------------------- |
| `cause`? | [`ErrorCause`](https://docs.vlt.io/client/api-reference/output/error.md#errorcause) |

---

### ParsedError

```ts
type ParsedError = object;
```

Defined in: error.ts:7

#### Type declaration

#### Index Signature

```ts
[key: string]: unknown
```

| Name      | Type                                                                                                                                                                            |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `cause`?  | \| [`ErrorCause`](https://docs.vlt.io/client/api-reference/output/error.md#errorcause) \| [`ParsedError`](https://docs.vlt.io/client/api-reference/output/error.md#parsederror) |
| `message` | `string`                                                                                                                                                                        |
| `name`    | `string`                                                                                                                                                                        |
| `stack`?  | `string`                                                                                                                                                                        |

## Functions

### asRootError()

```ts
function asRootError(v, match?): Omit<ParsedError, "cause"> & Required<Pick<ParsedError, "cause">>
```

Defined in: error.ts:59

Find the root error from an unknown value and throw if one is not found.

#### Parameters

| Parameter     | Type                  |
| ------------- | --------------------- |
| `v`           | `unknown`             |
| `match`?      | { `code`: `string`; } |
| `match.code`? | `string`              |

#### Returns

`Omit`<[`ParsedError`](https://docs.vlt.io/client/api-reference/output/error.md#parsederror), `"cause"`> & `Required`<`Pick`<[`ParsedError`](https://docs.vlt.io/client/api-reference/output/error.md#parsederror), `"cause"`>>

---

### findRootError()

```ts
function findRootError(v, match?): null | ParsedError
```

Defined in: error.ts:46

Find the root error from an unknown value, optionally matching a code.

#### Parameters

| Parameter     | Type                  |
| ------------- | --------------------- |
| `v`           | `unknown`             |
| `match`?      | { `code`: `string`; } |
| `match.code`? | `string`              |

#### Returns

`null` | [`ParsedError`](https://docs.vlt.io/client/api-reference/output/error.md#parsederror)

---

### parseError()

```ts
function parseError(err): null | ParsedError
```

Defined in: error.ts:19

Parse an unknown value into an error. Will also take enumerable properties from legacy style Node errors and treat them as the cause.

#### Parameters

| Parameter | Type      |
| --------- | --------- |
| `err`     | `unknown` |

#### Returns

`null` | [`ParsedError`](https://docs.vlt.io/client/api-reference/output/error.md#parsederror)
