1.2.0 • Published 7 years ago

with-stacktrace v1.2.0

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

with-stacktrace

A helper to catch errors from asynchronous tasks with prior stacktrace

Installation

npm install --save with-stacktrace

or

yarn add with-stacktrace

Example Usage

import withStacktrace from 'with-stacktrace';

function a() {
  b(); 
}

function b() {
  withStacktrace(new Promise(function asyncTask(resolve, reject) { 
    setTimeout(() => {
      reject(new Error('async error'));
    });
  })).catch(function(errorWithTrace) {
    console.log(errorWithTrace.stack);

    /* captured stacktrace (before using withStacktrace)
      Error: async error
        at setTimeout
    */

    /* captured stacktrace (after using withStacktrace)
      Error: async error
        at setTimeout (pen.js:32)
        at b (pen.js:30)
        at a (pen.js:26)
        at pen.js:40
    */
  });
}

a();
1.2.0

7 years ago

1.1.0

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.11111111111

7 years ago

1.0.0

7 years ago