Simple way to combine multiple errors into one.
Simple way to combine multiple errors into one.
This is useful for handling multiple asynchronous errors, where you want to catch all the errors and combine them to return just a single error.
error instanceof Error === true
error([error([err1, err2]), err3])
error(err).message === err.message && error(err).stack === err.stack
npm install combine-errors
var error = require('combine-errors')
var err = error([
new Error('boom'),
new Error('kablam')
])
throw err
/*
=>
Error: boom
at repl:2:1
at REPLServer.defaultEval (repl.js:262:27)
at bound (domain.js:287:14)
at REPLServer.runBound [as eval] (domain.js:300:12)
at REPLServer.<anonymous> (repl.js:431:12)
at emitOne (events.js:95:20)
at REPLServer.emit (events.js:182:7)
at REPLServer.Interface._onLine (readline.js:211:10)
at REPLServer.Interface._line (readline.js:550:8)
at REPLServer.Interface._ttyWrite (readline.js:827:14)
Error: kablam
at repl:3:1
at REPLServer.defaultEval (repl.js:262:27)
at bound (domain.js:287:14)
at REPLServer.runBound [as eval] (domain.js:300:12)
at REPLServer.<anonymous> (repl.js:431:12)
at emitOne (events.js:95:20)
at REPLServer.emit (events.js:182:7)
at REPLServer.Interface._onLine (readline.js:211:10)
at REPLServer.Interface._line (readline.js:550:8)
at REPLServer.Interface._ttyWrite (readline.js:827:14)
*/
MIT