Make Error Cause
Make your own nested errors.
Features
- Compatible with node.js and browsers
- Works with
instanceof
- Output full stack trace with
fullStack(err)
- Automatic full stack traces with node.js (via
inspect()
) - Extends
make-error
Installation
npm install make-error-cause --save
Usage
import { BaseError, fullStack } from 'make-error-cause'
class CustomError extends BaseError {
constructor (message, cause) {
super(message, cause)
}
}
const error = new Error('Boom!')
const customError = new CustomError('Another boom!', error)
console.log(fullStack(error))
console.log(fullStack(customError))
console.log(customError instanceof Error)
Attribution
Inspired by verror
, and others, but created lighter and without core dependencies for browser usage.
Other references:
License
Apache 2.0