JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5575164
  • Score
    100M100P100Q223139F
  • License MIT

An Error subclass that will chain nested Errors and dump nested stacktraces

Package Exports

  • nested-error-stacks

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (nested-error-stacks) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Nested stacktraces for Node.js!

Build Status NPM version Dependency Status

With this module, you can wrap a caught exception with extra context for better debugging. For example, a network error's stack would normally look like this:

Error: connect ECONNREFUSED
    at errnoException (net.js:904:11)
    at Object.afterConnect [as oncomplete] (net.js:895:19)

Using this module, you can wrap the Error with more context to get a stack that looks like this:

NestedError: Failed to communicate with localhost:8080
    at Socket.<anonymous> (/Users/mattlavin/Projects/nested-stacks/demo.js:6:18)
    at Socket.EventEmitter.emit (events.js:95:17)
    at net.js:440:14
    at process._tickCallback (node.js:415:13)
Caused By: Error: connect ECONNREFUSED
    at errnoException (net.js:904:11)
    at Object.afterConnect [as oncomplete] (net.js:895:19)

How to wrap errors

Here is an example program that uses this module to add more context to errors:

var NestedError = require('nested-error-stacks');
var net = require('net');

var client = net.connect({port: 8080});
client.on('error', function (err) {
var newErr = new NestedError("Failed to communicate with localhost:8080", err);
    console.log(newErr.stack);
});