error-trapper
v0.3.3
Published
[![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
Downloads
5
Readme
Error Trapper
Install
Install from npm:
npm install -D error-trapper
And add babel-macros
plugin to your babel config.
Usage
For wrap function:
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:
Or print with ErrorTrap.printContext
:
For parse scope:
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 );
} );
}