# @seudev/js-error

> A lightweight library, that provides an Error class to throws errors with cause, making it easier to chaining of errors.

Latest version **0.0.2** (published 2019-05-18) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @seudev/js-error
pnpm add @seudev/js-error
yarn add @seudev/js-error
bun add @seudev/js-error
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2019-05-18 |
| First published | 2019-05-18 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 14.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Thomás Sousa Silva |
| Maintainers | thomassousa96 |
| Keywords | error, error cause, error chain, debugging, Seudev |

## Links

- npm: https://www.npmjs.com/package/@seudev/js-error
- Repository: https://github.com/seudev/js-error
- Homepage: https://github.com/seudev/js-error#readme
- Issues: https://github.com/seudev/js-error/issues
- npm.io page: https://npm.io/package/@seudev/js-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

- 0.0.2 (latest) — 2019-05-18
- 0.0.1 — 2019-05-18

## README

# JS Error

## What is it?

A lightweight library, that provides an Error class to throws errors with cause, making it easier to chaining of errors.

## Using JS Error

```javascript
npm i @seudev/js-error
```

The `JSError` class is a subclass of `Error` class. Create instances of this class passing a message and a cause (optional). The message can be an string or an object.

```javascript
throw new JSError("Foo");

throw new JSError("Foo", cause);

throw new JSError({name: "ValidationError", message: "Foo"}, cause);

throw new JSError({name: "ValidationError", message: "Foo"}, cause);

throw new JSError({name: "ValidationError", message: "Foo", data: {}}, cause);
```

With this class you can do error handling an throws a new error passing the cause of this error.

```javascript
try {
    throw new Error("Foo");
} catch(ex) {
    throw new JSError("Bar", ex);
}
```
This code will generate a stacktrace like this:

![stacktrace](https://user-images.githubusercontent.com/8549602/57972828-0b0cc980-7976-11e9-990b-3d3692805e07.png)

## Licensing

**seudev/js-error** is provided and distributed under the [Apache Software License 2.0](http://www.apache.org/licenses/LICENSE-2.0).

Refer to *LICENSE* for more information.

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