# error-trapper

> [![Build Status](https://travis-ci.org/shamcode/error-trapper.svg?branch=master)](https://travis-ci.org/shamcode/error-trapper) [![npm version](https://badge.fury.io/js/error-trapper.svg)](https://badge.fury.io/js/error-trapper) [![Dependency Status](http

Latest version **0.3.3** (published 2017-10-10) · MIT license · 0 weekly downloads

## Install

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

## 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.3.3 |
| Published | 2017-10-10 |
| First published | 2017-09-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 7.* |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | sham |
| Maintainers | shamcode |
| Keywords | babel-macros, errors, debug |

## Links

- npm: https://www.npmjs.com/package/error-trapper
- Repository: https://github.com/shamcode/error-trapper
- Homepage: https://github.com/shamcode/error-trapper#readme
- Issues: https://github.com/shamcode/error-trapper/issues
- npm.io page: https://npm.io/package/error-trapper

## Dependencies (2)

- [babel-macros](https://npm.io/package/babel-macros.md) ^1.0.2
- [babel-generator](https://npm.io/package/babel-generator.md) ^6.26.0

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.3.3 (latest) — 2017-10-10
- 0.3.2 — 2017-10-10
- 0.3.1 — 2017-09-29
- 0.3.0 — 2017-09-28
- 0.2.0 — 2017-09-28
- 0.1.1 — 2017-09-25
- 0.1.0 — 2017-09-22
- 0.0.4 — 2017-09-22
- 0.0.3 — 2017-09-09
- 0.0.2 — 2017-09-09
- 0.0.1 — 2017-09-09

## README

# Error Trapper
[![Build Status](https://travis-ci.org/shamcode/error-trapper.svg?branch=master)](https://travis-ci.org/shamcode/error-trapper)
[![npm version](https://badge.fury.io/js/error-trapper.svg)](https://badge.fury.io/js/error-trapper)
[![Dependency Status](https://david-dm.org/shamcode/error-trapper.svg)](https://david-dm.org/shamcode/error-trapper)
[![devDependency Status](https://david-dm.org/shamcode/error-trapper.svg)](https://david-dm.org/shamcode/error-trapper#info=devDependencies)
[![MIT Licence](https://badges.frapsoft.com/os/mit/mit.svg?v=103)](https://opensource.org/licenses/mit-license.php)

### Install
Install from npm:
`npm install -D error-trapper`

And add `babel-macros` plugin to your babel config. 

### Usage
For wrap function:
```js
import initialize from 'error-trapper';
import WRAP from 'error-trapper/macros/wrap-function.macro';

initialize( `${window.location.hash}../node_modules/error-trapper/lib/esprima-bundle.js` );

WRAP( () => {
    const foo = { firstName: 'Andy' };
    const bar = foo.lastName.toString;
}, ( e, scope ) => {
    console.dir( scope );
} )();
```

Console output:

![Console output](https://github.com/shamcode/error-trapper/blob/master/screens/console-dir.png?raw=true)

Or print with `ErrorTrap.printContext`:

![Console output](https://github.com/shamcode/error-trapper/blob/master/screens/print-context.png?raw=true)

For parse scope:
```js
import initialize from 'error-trapper';
import PARSE_SCOPE from 'error-trapper/macros/parse-scope.macro';

initialize( `${window.location.hash}../node_modules/error-trapper/lib/esprima-bundle.js` );

try {
    const foo = { firstName: 'Andy' };
    const bar = foo.lastName.toString;
} catch (e) {
    PARSE_SCOPE( ( scope ) => {
        console.dir( scope );
    } );
}
```

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