# simple-errors

> Errors constructor for simple error handling.

Latest version **1.0.1** (published 2015-03-06) · BSD license · 0 weekly downloads

## Install

```sh
npm install simple-errors
pnpm add simple-errors
yarn add simple-errors
bun add simple-errors
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2015-03-06 |
| First published | 2013-01-11 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 33 |
| Author | Gustavo Machado |
| Maintainers | machadogj, kidozen |
| Keywords | error |

## Links

- npm: https://www.npmjs.com/package/simple-errors
- Repository: https://github.com/machadogj/node-simple-errors
- Issues: https://github.com/machadogj/node-simple-errors/issues
- npm.io page: https://npm.io/package/simple-errors

## Dependencies (1)

- [errno](https://npm.io/package/errno.md) ^0.1.1

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

- 1.0.1 (latest) — 2015-03-06
- 1.0.0 — 2014-11-10
- 0.0.5 — 2014-07-21
- 0.0.4 — 2013-02-25
- 0.0.3 — 2013-01-22
- 0.0.2 — 2013-01-11
- 0.0.1 — 2013-01-11

## README

#simple-errors
Factory methods for easy error handling.

##Installation

```sh
npm install simple-errors
```

##Usage
Just make sure to require the module somewhere in your code (only once)

```js
require('simple-errors');
```

Then use the factory methods for creating errors:

```js
//simplest of errors
var err = Error.create();

//with message
var err = Error.create('foo');
console.log(err.message === 'foo'); //prints true

//with data
var err = Error.create('foo', { foo: 'bar' });
console.log(err.message === 'foo'); //prints true
console.log(err.foo === 'bar'); //prints true

//with data and inner error
var err = Error.create('foo', { foo: 'bar' }, err);
console.log(err.message === 'foo'); //prints true
console.log(err.foo === 'bar'); //prints true
console.log(err.inner === err); //prints true

//helper for status codes (for use with connect & express)
var err = Error.http(500);
console.log(err.status === 500); //prints true

//helper for status codes, with message, data and error
var err = Error.http(500, 'foo', {foo: 'bar'}, err);
console.log(err.status === 500); //prints true
console.log(err.message === 'foo'); //prints true
console.log(err.foo === 'bar'); //prints true
console.log(err.inner === err); //prints true

//helper method for turning the Error instance into a json object
var err = Error.create();
var obj = Error.toJson(err); //use this to print the entire error with stack.

```

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