# es6-error

> Easily-extendable error for use with ES6 classes

Latest version **4.1.1** (published 2018-01-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install es6-error
pnpm add es6-error
yarn add es6-error
bun add es6-error
```

## Health

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

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.1.1 |
| Published | 2018-01-03 |
| First published | 2015-03-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 212 |
| Author | Ben Youngblood |
| Maintainers | bjy |
| Keywords | es6, error, babel |

## Links

- npm: https://www.npmjs.com/package/es6-error
- Repository: https://github.com/bjyoungblood/es6-error
- Issues: https://github.com/bjyoungblood/es6-error/issues
- npm.io page: https://npm.io/package/es6-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.1.1 (latest) — 2018-01-03
- 4.1.0 — 2018-01-02
- 4.0.2 — 2017-02-08
- 4.0.1 — 2017-01-04
- 4.0.0 — 2016-10-03
- 3.2.0 — 2016-09-29
- 3.1.0 — 2016-09-08
- 3.0.1 — 2016-07-14
- 3.0.0 — 2016-05-18
- 2.1.1 — 2016-05-02
- 2.1.0 — 2016-03-08
- 2.0.2 — 2015-11-04
- 2.0.1 — 2015-10-22
- 2.0.0 — 2015-09-16
- 1.0.0 — 2015-03-28

## README

# es6-error

[![npm version](https://badge.fury.io/js/es6-error.svg)](https://www.npmjs.com/package/es6-error)
[![Build Status](https://travis-ci.org/bjyoungblood/es6-error.svg?branch=master)](https://travis-ci.org/bjyoungblood/es6-error)

An easily-extendable error class for use with ES6 classes (or ES5, if you so
choose).

Tested in Node 4.0, Chrome, and Firefox.

## Why?

I made this because I wanted to be able to extend Error for inheritance and type
checking, but can never remember to add
`Error.captureStackTrace(this, this.constructor.name)` to the constructor or how
to get the proper name to print from `console.log`.

## ES6 Usage

```javascript

import ExtendableError from 'es6-error';

class MyError extends ExtendableError {
  // constructor is optional; you should omit it if you just want a custom error
  // type for inheritance and type checking
  constructor(message = 'Default message') {
    super(message);
  }
}

export default MyError;
```

## ES5 Usage

```javascript

var util = require('util');
var ExtendableError = require('es6-error');

function MyError(message) {
  message = message || 'Default message';
  ExtendableError.call(this, message);
}

util.inherits(MyError, ExtendableError);

module.exports = MyError;
```

### Known Issues

- Uglification can obscure error class names ([#31](https://github.com/bjyoungblood/es6-error/issues/31#issuecomment-301128220))

#### Todo

- Better browser compatibility
- Browser tests

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