All Projects → mdlavin → nested-error-stacks

mdlavin / nested-error-stacks

Licence: MIT license
A node.js module for creating Error objects with nested Errors in stacktraces

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to nested-error-stacks

Rollbar Android
Rollbar for Android
Stars: ✭ 41 (-52.33%)
Mutual labels:  stack-traces, error-handling
Make Error Cause
Make your own nested errors
Stars: ✭ 36 (-58.14%)
Mutual labels:  stack-traces, error-handling
Errorx
A comprehensive error handling library for Go
Stars: ✭ 712 (+727.91%)
Mutual labels:  stack-traces, error-handling
Ben.demystifier
High performance understanding for stack traces (Make error logs more productive)
Stars: ✭ 2,142 (+2390.7%)
Mutual labels:  stack-traces, error-handling
auto-async-wrap
automatic async middleware wrapper for expressjs errorhandler.
Stars: ✭ 21 (-75.58%)
Mutual labels:  error-handling
ngx-errors
Angular directives for displaying validation errors
Stars: ✭ 51 (-40.7%)
Mutual labels:  error-handling
go-errors
⚠️ Better GoLang error handling.
Stars: ✭ 18 (-79.07%)
Mutual labels:  error-handling
classy-optics
🔎 Source code shown at my talks at Scale by the Bay 2018 and Scalar 2019
Stars: ✭ 25 (-70.93%)
Mutual labels:  error-handling
optionals
Rust-like error handling and options for TypeScript and Deno!
Stars: ✭ 97 (+12.79%)
Mutual labels:  error-handling
go-errors
A super tiny package for error encapsulation in idiomatic Go
Stars: ✭ 14 (-83.72%)
Mutual labels:  error-handling
SolveWithStack
Android library for helping you to reach out to best possible answer for your bug/error available on stack overflow and will show it in your Android Studio Console only.
Stars: ✭ 15 (-82.56%)
Mutual labels:  error-handling
rakered
The open source components from rake.red
Stars: ✭ 28 (-67.44%)
Mutual labels:  error-handling
koa-better-error-handler
A better error-handler for Lad and Koa. Makes `ctx.throw` awesome (best used with koa-404-handler)
Stars: ✭ 51 (-40.7%)
Mutual labels:  error-handling
ignition-stackoverflow
An Ignition tab that fetches StackOverflow questions and provides a searchbar.
Stars: ✭ 74 (-13.95%)
Mutual labels:  error-handling
raygun4android
Android crash reporting provider for Raygun
Stars: ✭ 19 (-77.91%)
Mutual labels:  error-handling
sealed-monad
Scala library for nice business logic oriented, for-comprehension-style error handling
Stars: ✭ 16 (-81.4%)
Mutual labels:  error-handling
redux-airbrake
Redux middleware for Airbrake error logging
Stars: ✭ 20 (-76.74%)
Mutual labels:  error-handling
express-error-slack
Express error handling middleware for reporting error to Slack
Stars: ✭ 14 (-83.72%)
Mutual labels:  error-handling
TrackJS-Node
TrackJS Error Monitoring agent for NodeJS
Stars: ✭ 26 (-69.77%)
Mutual labels:  error-handling
stack-trace-art
Turning programming exceptions into art
Stars: ✭ 39 (-54.65%)
Mutual labels:  stack-traces

Nested stacktraces for Node.js!

Build Status NPM version

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';
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].