# make-error-cause

> Make your own nested error types!

Latest version **2.3.0** (published 2019-11-06) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install make-error-cause
pnpm add make-error-cause
yarn add make-error-cause
bun add make-error-cause
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.3.0 |
| Published | 2019-11-06 |
| First published | 2015-12-12 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 8.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 69 |
| Author | Blake Embrey |
| Maintainers | blakeembrey |
| Keywords | nested, error, cause, extend, inherit, custom |

## Links

- npm: https://www.npmjs.com/package/make-error-cause
- Repository: https://github.com/blakeembrey/make-error-cause
- Issues: https://github.com/blakeembrey/make-error-cause/issues
- npm.io page: https://npm.io/package/make-error-cause

## Dependencies (1)

- [make-error](https://npm.io/package/make-error.md) ^1.3.5

## 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

- 2.3.0 (latest) — 2019-11-06
- 2.2.1 — 2019-07-10
- 2.2.0 — 2018-05-26
- 2.1.0 — 2018-05-19
- 2.0.0 — 2018-04-01
- 1.2.2 — 2016-10-18
- 1.2.1 — 2016-07-20
- 1.2.0 — 2016-07-20
- 1.1.1 — 2016-06-20
- 1.1.0 — 2016-03-08
- 1.0.2 — 2016-01-03
- 1.0.1 — 2015-12-12
- 1.0.0 — 2015-12-12

## README

# Make Error Cause

[![NPM version][npm-image]][npm-url]
[![NPM downloads][downloads-image]][downloads-url]
[![Build status][travis-image]][travis-url]
[![Test coverage][coveralls-image]][coveralls-url]

> Make your own nested errors.

## Features

- Compatible with node.js and browsers
- Works with `instanceof`
- Automatic full stack traces in node.js (supports [`inspect()`](https://nodejs.org/api/util.html#util_util_inspect_object_options))
- Output full stack trace with `fullStack(err)`
- Extends [`make-error`](https://github.com/JsCommunity/make-error)

## Installation

```
npm install make-error-cause --save
```

## Usage

```js
import { BaseError, fullStack } from "make-error-cause";

class CustomError extends BaseError {
  constructor(message, cause) {
    super(message, cause);
  }
}

const error = new Error("Boom!");
const customError = new CustomError("Another boom!", error);

console.log(customError); // Automatically prints full stack trace using `fullStack(this)`.
console.log(customError.cause); // Check causes via the `.cause` property.

console.log(customError instanceof Error); //=> true
```

## Attribution

Inspired by [`verror`](https://www.npmjs.com/package/verror), and others, but created lighter and without core dependencies for browser usage.

Other references:

- [Java](https://docs.oracle.com/javase/7/docs/api/java/lang/Exception.html)
- [Python](https://www.python.org/dev/peps/pep-3134/)

## License

Apache 2.0

[npm-image]: https://img.shields.io/npm/v/make-error-cause.svg?style=flat
[npm-url]: https://npmjs.org/package/make-error-cause
[downloads-image]: https://img.shields.io/npm/dm/make-error-cause.svg?style=flat
[downloads-url]: https://npmjs.org/package/make-error-cause
[travis-image]: https://img.shields.io/travis/blakeembrey/make-error-cause.svg?style=flat
[travis-url]: https://travis-ci.org/blakeembrey/make-error-cause
[coveralls-image]: https://img.shields.io/coveralls/blakeembrey/make-error-cause.svg?style=flat
[coveralls-url]: https://coveralls.io/r/blakeembrey/make-error-cause?branch=master

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