JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 487442
  • Score
    100M100P100Q176254F
  • License Apache-2.0

Make your own nested error types!

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

NPM version NPM downloads Build status Test coverage

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)) // Works with any error.
console.log(fullStack(customError)) // Extended stack trace contains error causes.

console.log(customError instanceof Error) //=> true

Attribution

Inspired by verror, and others, but created lighter and without core dependencies for browser usage.

Other references:

License

Apache 2.0