Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
better node.js stacktraces from event triggered code
// the stack trace you really want that tells you how you originally got to the fs.readFile call
var stacktrace = new Error()
Error.captureStackTrace(stacktrace)
fs.readFile( path, encoding, function(err,data) {
if( err ) {
var stackerr = new Error('Unable to read file: '+path+' (error code: '+err.code+')')
stackerr.errno = err.errno
stackerr.code = err.code
stackerr.path = err.path
stackerr.stack = stacktrace.stack
return callback(stackerr)
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.