Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

extensible-error

justmoon5.2kISC1.0.2TypeScript support: included

Error base class for Node.js/browsers

error, es6, es2015, extends, extensible, base, class, inherit, stack

readme

ExtensibleError

Error base class for Node.js/browsers

Unfortunately, JavaScript's built-in Error can't simply be extended like any other class. This module provides a class for Node.js and the browser which is designed to behave like Error, but be extensible like any other ES2015 class.

Installation

npm install --save extensible-error

Usage

const ExtensibleError = require('extensible-error')

class CustomError extends ExtensibleError {
  constructor (message, extra) {
    super(message)

    this.extra = extra
  }
}