# with-stacktrace

> catch errors of asynchronous functions with prior stacktrace

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

## Install

```sh
npm install with-stacktrace
pnpm add with-stacktrace
yarn add with-stacktrace
bun add with-stacktrace
```

## 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.2.0 |
| Published | 2017-10-25 |
| First published | 2017-09-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | sagiavinash |
| Maintainers | sagiavinashvarma |
| Keywords | javascript, debugging, error, stacktrace, async |

## Links

- npm: https://www.npmjs.com/package/with-stacktrace
- Repository: https://github.com/sagiavinash/with-stacktrace
- Homepage: https://github.com/sagiavinash/with-stacktrace#readme
- Issues: https://github.com/sagiavinash/with-stacktrace/issues
- npm.io page: https://npm.io/package/with-stacktrace

## 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.2.0 (latest) — 2017-10-25
- 1.1.0 — 2017-10-11
- 1.0.3 — 2017-09-28
- 1.0.2 — 2017-09-28
- 1.0.1 — 2017-09-23
- 1.0.11111111111 — 2017-09-23
- 1.0.0 — 2017-09-23

## README

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
-------------
```javascript
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();
```

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