make-error-cause
Make your own nested error types!
Last updated 9 years ago by blakeembrey .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ npm install make-error-cause 
SYNC missed versions from official npm registry.

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
  • Automatic full stack traces in node.js (supports inspect())
  • Output full stack trace with fullStack(err)
  • 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(customError); // Automatically prints full stack trace using `fullStack(this)`.
console.log(customError.cause); // Check causes via the `.cause` property.

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

Current Tags

  • 2.3.0                                ...           latest (5 years ago)

13 Versions

  • 2.3.0                                ...           5 years ago
  • 2.2.1                                ...           5 years ago
  • 2.2.0                                ...           6 years ago
  • 2.1.0                                ...           6 years ago
  • 2.0.0                                ...           7 years ago
  • 1.2.2                                ...           8 years ago
  • 1.2.1                                ...           8 years ago
  • 1.2.0                                ...           8 years ago
  • 1.1.1                                ...           8 years ago
  • 1.1.0                                ...           9 years ago
  • 1.0.2                                ...           9 years ago
  • 1.0.1                                ...           9 years ago
  • 1.0.0                                ...           9 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (8)

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