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

# Reference

## Type Aliases

### Codes

```ts
type Codes = 
  | "EEXIST"
  | "EINTEGRITY"
  | "EINVAL"
  | "ELIFECYCLE"
  | "EMAXREDIRECT"
  | "ENEEDAUTH"
  | "ENOENT"
  | "ENOGIT"
  | "ERESOLVE"
  | "EUNKNOWN"
  | "EUSAGE"
  | "EQUERY"
  | "EREQUEST"
  | "ECONFIG"
  | "ELOCKFILEVERSION"
  | "EINVALIDNAME";
```

Defined in: index.ts:196

Valid properties for the 'code' field in an Error cause. Add new options to this list as needed.

---

### DuckTypeManifest

```ts
type DuckTypeManifest = Record<string, any> & object;
```

Defined in: index.ts:172

#### Type declaration

| Name                 | Type                         |
| -------------------- | ---------------------------- |
| `arch`?              | `string`\[] \| `string`      |
| `deprecated`?        | `string`                     |
| `dist`?              | `object`                     |
| `dist.fileCount`?    | `number`                     |
| `dist.integrity`?    | `string`                     |
| `dist.shasum`?       | `string`                     |
| `dist.signatures`?   | `object`\[]                  |
| `dist.tarball`?      | `string`                     |
| `dist.unpackedSize`? | `number`                     |
| `engines`?           | `Record`<`string`, `string`> |
| `name`?              | `string`                     |
| `os`?                | `string`\[] \| `string`      |
| `version`?           | `string`                     |

---

### ErrorCauseOptions

```ts
type ErrorCauseOptions = object;
```

Defined in: index.ts:13

Codification of vlt's Error.cause conventions

Add new properties to this list as needed.

Several of these types are just very basic duck-typing, because referencing internal types directly would create a workspace dependency cycle.

#### Type declaration

| Name                  | Type                                                                                                                         | Description                                                                                                                                                                                                                                                                                                                                                                                                                  |
| --------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `args`?               | `string`\[]                                                                                                                  | the arguments passed to a process                                                                                                                                                                                                                                                                                                                                                                                            |
| `cause`?              | `unknown`                                                                                                                    | The `cause` field within a `cause` object should always be an `Error` object that was previously thrown. Note that the `cause` on an Error itself might _also_ be a previously thrown error, if no additional information could be usefully added beyond improving the message. It is typed as `unknown` because we use `useUnknownInCatchVariables` so this makes it easier to rethrow a caught error without recasting it. |
| `code`?               | [`Codes`](https://docs.vlt.io/client/api-reference/error-cause/reference.md#codes)                                           | This should only be a string code that we set. See [Codes](https://docs.vlt.io/client/api-reference/error-cause/reference.md#codes) for the supported options. Lower-level system codes like `ENOENT` should remain on the errors that generated them.                                                                                                                                                                       |
| `command`?            | `string`                                                                                                                     | a command being run in a child process                                                                                                                                                                                                                                                                                                                                                                                       |
| `cwd`?                | `string`                                                                                                                     | the current working directory of a process                                                                                                                                                                                                                                                                                                                                                                                   |
| `found`?              | `unknown`                                                                                                                    | actual value, which was not wanted                                                                                                                                                                                                                                                                                                                                                                                           |
| `from`?               | `string`                                                                                                                     | file path origin of a resolution that failed, for example in the case of `file://` specifiers.                                                                                                                                                                                                                                                                                                                               |
| `manifest`?           | [`DuckTypeManifest`](https://docs.vlt.io/client/api-reference/error-cause/reference.md#ducktypemanifest)                     | a package manifest, either from `package.json` or a registry                                                                                                                                                                                                                                                                                                                                                                 |
| `max`?                | `unknown`                                                                                                                    | maximum value, which was exceeded                                                                                                                                                                                                                                                                                                                                                                                            |
| `method`?             | `string`                                                                                                                     | HTTP method                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `min`?                | `unknown`                                                                                                                    | minimum value, which was not met                                                                                                                                                                                                                                                                                                                                                                                             |
| `name`?               | `string`                                                                                                                     | the name of something                                                                                                                                                                                                                                                                                                                                                                                                        |
| `offset`?             | `number`                                                                                                                     | byte offset in a Buffer or file                                                                                                                                                                                                                                                                                                                                                                                              |
| `packument`?          | `object`                                                                                                                     | registry top-level package document                                                                                                                                                                                                                                                                                                                                                                                          |
| `packument.dist-tags` | `Record`<`string`, `string`>                                                                                                 | -                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `packument.name`      | `string`                                                                                                                     | -                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `packument.time`?     | `Record`<`string`, `string`>                                                                                                 | -                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `packument.versions`  | `Record`<`string`, [`DuckTypeManifest`](https://docs.vlt.io/client/api-reference/error-cause/reference.md#ducktypemanifest)> | -                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `path`?               | `string`                                                                                                                     | target of a file system operation                                                                                                                                                                                                                                                                                                                                                                                            |
| `projectRoot`?        | `string`                                                                                                                     | the root of a project                                                                                                                                                                                                                                                                                                                                                                                                        |
| `range`?              | \| `string` \| { \`\[k: string                                                                                               | number                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `repository`?         | `string`                                                                                                                     | git repository remote or path                                                                                                                                                                                                                                                                                                                                                                                                |
| `response`?           | \| `IncomingMessage` \| `Response` \| { \`\[k: string                                                                        | number                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `signal`?             | `NodeJS.Signals` \| `null`                                                                                                   | null or a signal that a process received                                                                                                                                                                                                                                                                                                                                                                                     |
| `spec`?               | \| `string` \| { \`\[k: string                                                                                               | number                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `status`?             | `number` \| `null`                                                                                                           | exit code of a process, or HTTP response status code                                                                                                                                                                                                                                                                                                                                                                         |
| `stderr`?             | `Buffer` \| `string` \| `null`                                                                                               | standard error from a process                                                                                                                                                                                                                                                                                                                                                                                                |
| `stdout`?             | `Buffer` \| `string` \| `null`                                                                                               | standard output from a process                                                                                                                                                                                                                                                                                                                                                                                               |
| `target`?             | `string`                                                                                                                     | path on disk that is being written, linked, or extracted to                                                                                                                                                                                                                                                                                                                                                                  |
| `todo`?               | `string`                                                                                                                     | message indicating what bit of work this might be a part of, what feature needs to be implemented, etc. Eg, `{ todo: 'nested workspace support' }`.                                                                                                                                                                                                                                                                          |
| `url`?                | `URL` \| `string`                                                                                                            | string or URL object                                                                                                                                                                                                                                                                                                                                                                                                         |
| `validOptions`?       | `unknown`\[] \| readonly `unknown`\[]                                                                                        | Array of valid options when something is not a valid option. (For use in `did you mean X?` output.)                                                                                                                                                                                                                                                                                                                          |
| `version`?            | \| `string` \| { \`\[k: string                                                                                               | number                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `wanted`?             | `unknown`                                                                                                                    | A desired value that was not found, or a regular expression or other pattern describing it.                                                                                                                                                                                                                                                                                                                                  |

---

### ErrorCtor()\<T>

```ts
type ErrorCtor<T> = (message, options?) => T;
```

Defined in: index.ts:220

#### Type Parameters

| Type Parameter        |
| --------------------- |
| `T` _extends_ `Error` |

#### Parameters

| Parameter        | Type                                                                                                                                |
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| `message`        | `string`                                                                                                                            |
| `options`?       | { `cause`: `Error` \| [`ErrorCauseOptions`](https://docs.vlt.io/client/api-reference/error-cause/reference.md#errorcauseoptions); } |
| `options.cause`? | `Error` \| [`ErrorCauseOptions`](https://docs.vlt.io/client/api-reference/error-cause/reference.md#errorcauseoptions)               |

#### Returns

`T`

## Functions

### error()

#### Call Signature

```ts
function error(
   message, 
   cause?, 
   from?): Error
```

Defined in: index.ts:258

##### Parameters

| Parameter | Type        |
| --------- | ----------- |
| `message` | `string`    |
| `cause`?  | `undefined` |
| `from`?   | `Function`  |

##### Returns

`Error`

#### Call Signature

```ts
function error(
   message, 
   cause, 
   from?): Error & object
```

Defined in: index.ts:263

##### Parameters

| Parameter | Type       |
| --------- | ---------- |
| `message` | `string`   |
| `cause`   | `Error`    |
| `from`?   | `Function` |

##### Returns

`Error` & `object`

#### Call Signature

```ts
function error(
   message, 
   cause, 
   from?): Error & object
```

Defined in: index.ts:268

##### Parameters

| Parameter | Type                                                                                                       |
| --------- | ---------------------------------------------------------------------------------------------------------- |
| `message` | `string`                                                                                                   |
| `cause`   | [`ErrorCauseOptions`](https://docs.vlt.io/client/api-reference/error-cause/reference.md#errorcauseoptions) |
| `from`?   | `Function`                                                                                                 |

##### Returns

`Error` & `object`

---

### syntaxError()

#### Call Signature

```ts
function syntaxError(
   message, 
   cause?, 
   from?): SyntaxError
```

Defined in: index.ts:304

##### Parameters

| Parameter | Type        |
| --------- | ----------- |
| `message` | `string`    |
| `cause`?  | `undefined` |
| `from`?   | `Function`  |

##### Returns

`SyntaxError`

#### Call Signature

```ts
function syntaxError(
   message, 
   cause, 
   from?): SyntaxError & object
```

Defined in: index.ts:309

##### Parameters

| Parameter | Type       |
| --------- | ---------- |
| `message` | `string`   |
| `cause`   | `Error`    |
| `from`?   | `Function` |

##### Returns

`SyntaxError` & `object`

#### Call Signature

```ts
function syntaxError(
   message, 
   cause, 
   from?): SyntaxError & object
```

Defined in: index.ts:314

##### Parameters

| Parameter | Type                                                                                                       |
| --------- | ---------------------------------------------------------------------------------------------------------- |
| `message` | `string`                                                                                                   |
| `cause`   | [`ErrorCauseOptions`](https://docs.vlt.io/client/api-reference/error-cause/reference.md#errorcauseoptions) |
| `from`?   | `Function`                                                                                                 |

##### Returns

`SyntaxError` & `object`

---

### typeError()

#### Call Signature

```ts
function typeError(
   message, 
   cause?, 
   from?): TypeError
```

Defined in: index.ts:281

##### Parameters

| Parameter | Type        |
| --------- | ----------- |
| `message` | `string`    |
| `cause`?  | `undefined` |
| `from`?   | `Function`  |

##### Returns

`TypeError`

#### Call Signature

```ts
function typeError(
   message, 
   cause, 
   from?): TypeError & object
```

Defined in: index.ts:286

##### Parameters

| Parameter | Type       |
| --------- | ---------- |
| `message` | `string`   |
| `cause`   | `Error`    |
| `from`?   | `Function` |

##### Returns

`TypeError` & `object`

#### Call Signature

```ts
function typeError(
   message, 
   cause, 
   from?): TypeError & object
```

Defined in: index.ts:291

##### Parameters

| Parameter | Type                                                                                                       |
| --------- | ---------------------------------------------------------------------------------------------------------- |
| `message` | `string`                                                                                                   |
| `cause`   | [`ErrorCauseOptions`](https://docs.vlt.io/client/api-reference/error-cause/reference.md#errorcauseoptions) |
| `from`?   | `Function`                                                                                                 |

##### Returns

`TypeError` & `object`
