# @pacote/error

> Functional errors.

Latest version **4.0.1** (published 2026-06-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install @pacote/error
pnpm add @pacote/error
yarn add @pacote/error
bun add @pacote/error
```

## Health

**Score 60/100 (C)** — status: active.

Positive: has types; esm support; no vulnerabilities; high maintenance score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 4.0.1 |
| Published | 2026-06-22 |
| First published | 2018-10-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 17.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Author | Luís Rodrigues |
| Maintainers | goblindegook |
| Keywords | error, fp, functional programming |

## Links

- npm: https://www.npmjs.com/package/@pacote/error
- Repository: https://github.com/PacoteJS/pacote
- Homepage: https://github.com/PacoteJS/pacote#readme
- Issues: https://github.com/PacoteJS/pacote/issues
- npm.io page: https://npm.io/package/@pacote/error

## Alternatives

- [@sentry/react-native](https://npm.io/package/@sentry/react-native.md) — 2.6M weekly downloads
- [@ardatan/aggregate-error](https://npm.io/package/@ardatan/aggregate-error.md) — 708.1K weekly downloads
- [custom-error-generator](https://npm.io/package/custom-error-generator.md) — 2.0K weekly downloads
- [@technik-sde/prosemirror-recreate-transform](https://npm.io/package/@technik-sde/prosemirror-recreate-transform.md) — 1.5K weekly downloads
- [@suchipi/error-utils](https://npm.io/package/@suchipi/error-utils.md) — 78 weekly downloads

## Recent versions

- 4.0.1 (latest) — 2026-06-22
- 4.0.0 — 2026-03-31
- 3.0.4 — 2025-02-25
- 3.0.3 — 2024-10-05
- 3.0.2 — 2023-08-25
- 3.0.1 — 2023-04-22
- 3.0.0 — 2023-04-13
- 2.1.7 — 2021-08-13
- 2.1.6 — 2020-11-27
- 2.1.5 — 2020-11-14
- 2.1.4 — 2020-09-05
- 2.1.3 — 2020-06-03
- 2.1.2 — 2020-01-06
- 2.1.1 — 2019-08-09
- 2.1.0 — 2019-08-07
- … 7 more at https://npm.io/package/@pacote/error/versions

## README

# @pacote/error

![version](https://badgen.net/npm/v/@pacote/error)
![minified](https://badgen.net/bundlephobia/min/@pacote/error)
![minified + gzip](https://badgen.net/bundlephobia/minzip/@pacote/error)

Custom error classes and utilities.

## Installation

```bash
yarn add @pacote/error
```

## Usage

### `BaseError`

`BaseError` is an error class which provides a convenience static `imprint()` method to get around [issues with extending the built-in JavaScript `Error` class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error). It's by no means a bullet-proof solution and full support is not available in older browsers (such as Internet Explorer up to version 10).

```typescript
import { BaseError } from '@pacote/error'

class StatusError extends BaseError {
  constructor(public readonly status: number, message?: string) {
    super(message)
    StatusError.imprint(this)
  }
}

const e = new StatusError(404, 'Not found')

e instanceOf Error       // true
e instanceOf BaseError   // true
e instanceOf StatusError // true
e.message                // 'Not found'
e.status                 // 404
e.stack                  // <defined>
```

### `ComplexError`

`ComplexError` aggregates multiple error objects so they can be thrown as one. Its primary use case is to support validation errors caused by multiple failing conditions.

```typescript
import { ComplexError } from '@pacote/error'

function doSomething() {
  throw new ComplexError('Could not do something', [
    new Error('one'),
    new Error('two'),
  ])
}

try {
  doSomething()
} catch (e) {
  e.causes.forEach(console.error) // Outputs Error('one'), Error('two')
}
```

## License

MIT © [Luís Rodrigues](https://goblindegook.com).

---
_Source: https://npm.io/package/@pacote/error · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
