combine-errors
Combine errors into one
Last updated a month ago by mattmueller .
Repository · Bugs · Original npm · Tarball · package.json
$ npm install combine-errors 
SYNC missed versions from official npm registry.

combine-errors

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.

Features

  • error instanceof Error === true
  • composable: error([error([err1, err2]), err3])
  • stack and message are combined in a nice way
  • array-like object, so you can access the original errors by looping over the error
  • If you just have one error, it looks exactly like raw error meaning, error(err).message === err.message && error(err).stack === err.stack
  • should work in the browser, though I haven't tested it yet

Installation

npm install combine-errors

Usage

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)
*/

License

This project is licensed under the MIT License - see the [./License.md] file for details.

Current Tags

  • 3.0.4                                ...           latest (a month ago)

8 Versions

  • 3.0.4                                ...           a month ago
  • 3.0.3                                ...           10 years ago
  • 3.0.2                                ...           10 years ago
  • 3.0.1                                ...           11 years ago
  • 3.0.0                                ...           11 years ago
  • 2.0.0                                ...           11 years ago
  • 1.0.1                                ...           11 years ago
  • 1.0.0                                ...           11 years ago
Downloads
Total 26
Today 0
This Week 0
This Month 18
Last Day 0
Last Week 11
Last Month 7
Dependencies (2)
Dev Dependencies (1)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE