nested-error-stacks

WebJar for nested-error-stacks

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

nested-error-stacks
Last Version

Last Version

2.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

nested-error-stacks
WebJar for nested-error-stacks
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/mdlavin/nested-error-stacks

Download nested-error-stacks

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/nested-error-stacks/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>nested-error-stacks</artifactId>
    <version>2.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/nested-error-stacks/
implementation 'org.webjars.npm:nested-error-stacks:2.0.1'
// https://jarcasting.com/artifacts/org.webjars.npm/nested-error-stacks/
implementation ("org.webjars.npm:nested-error-stacks:2.0.1")
'org.webjars.npm:nested-error-stacks:jar:2.0.1'
<dependency org="org.webjars.npm" name="nested-error-stacks" rev="2.0.1">
  <artifact name="nested-error-stacks" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='nested-error-stacks', version='2.0.1')
)
libraryDependencies += "org.webjars.npm" % "nested-error-stacks" % "2.0.1"
[org.webjars.npm/nested-error-stacks "2.0.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

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);
});

How to inherit

It is recommended to use explicit names for Error classes. You can do it like this:

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

function MyError(message, nested) {
    NestedError.call(this, message, nested);
}

util.inherits(MyError, NestedError);
MyError.prototype.name = 'MyError';

Versions

Version
2.0.1
2.0.0