// 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) } ...