# @tradle/errors

> match, ignore, rethrow error

Latest version **2.0.1** (published 2022-01-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install @tradle/errors
pnpm add @tradle/errors
yarn add @tradle/errors
bun add @tradle/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 | 2.0.1 |
| Published | 2022-01-20 |
| First published | 2018-01-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 15.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | mvayngrib |
| Maintainers | leichtgewicht, genevayngrib, tenaciousmv, pgmemk |
| Keywords | error, errors, rethrow, error-handling |

## Links

- npm: https://www.npmjs.com/package/@tradle/errors
- npm.io page: https://npm.io/package/@tradle/errors

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md) ^4.17.4

## 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.0.1 (latest) — 2022-01-20
- 2.0.0 — 2019-02-08
- 1.2.0 — 2019-01-27
- 1.1.1 — 2018-03-12
- 1.1.0 — 2018-01-14
- 1.0.1 — 2018-01-10
- 1.0.0 — 2018-01-10

## README

# @tradle/errors

error matching and rethrowing utils. Similar to https://github.com/hapijs/bounce

API is pretty self-explanatory, but see the example below. All three functions, `ignore`, `rethrow` and `matches` accept the same arguments: an error, and criteria (either an Error subclass or a set of properties to match).

`ignore`: ignores an error  
`rethrow`: rethrows an error   
`matches`: returns true if an error matches the provided criteria

```js
const createErrorType = require('error-ex')
const Errors = require('@tradle/errors')
const MyCustomError = createErrorType('MyCustomError')

try {
  throw new MyCustomError('blah')
} catch(err) {
  // ignored by comparing properties
  Errors.ignore(err, { message: 'blah' })
  // ignored by Error prototype chain
  Errors.ignore(err, MyCustomError)
  // ignore if any of these matches
  Errors.ignore(err, [
    MyCustomError,
    { message: 'floop' }
  ])

  // ignore by 'developer' alias
  // aliased to match TypeError, ReferenceError, EvalError etc.
  Errors.rethrow(err, 'developer')
}

try {
  blah
} catch(err) {
  // will ignore ReferenceError
  Errors.ignore(err, 'developer')
}

try {
  blah
} catch(err) {
  // will rethrow ReferenceError: blah is not defined
  Errors.rethrow(err, 'developer')
}
```

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