Package Exports
- make-error-cause
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (make-error-cause) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Make Error Cause
Make your own nested error types!
Features
- Compatible with Node and browsers
- Works with
instanceof - Use
error.stackanderror.name - Output full cause with
toString - Extends make-error
Installation
npm install make-error-cause --saveUsage
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!Attribution
Inspired by verror, and others, but created lighter and without core dependencies for browser usage.
License
Apache 2.0