sensordb2 e64a8defe5 3.17 | il y a 1 an | |
---|---|---|
.. | ||
dist | il y a 1 an | |
LICENSE | il y a 1 an | |
README.md | il y a 1 an | |
package.json | il y a 1 an |
Make your own nested error types!
instanceof
error.stack
and error.name
toString
npm install make-error-cause --save
Usages from make-error
. The only difference is that errors accept a second argument known as the error "cause". The cause is used to wrap original errors with more intuitive feedback - for instance, wrapping a raw database error in a HTTP error.
const CustomError = makeErrorCause('CustomError')
const cause = new Error('boom!')
const error = new CustomError('something bad', cause)
error.toString() //=> "CustomError: something bad\nCaused by: boom!"
error.stack // Works!
error.cause.stack // Handy!
Inspired by verror
, and others, but created lighter and without core dependencies for browser usage.
Apache 2.0