Socket
Socket
Sign inDemoInstall

make-error-cause

Package Overview
Dependencies
1
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    make-error-cause

Make your own nested error types!


Version published
Weekly downloads
414K
decreased by-19.86%
Maintainers
1
Install size
21.9 kB
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 06 Nov 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc