extensible-error
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

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
  }
}

/extensible-error/

    Package Sidebar

    Install

    npm i extensible-error

    Weekly Downloads

    881

    Version

    1.0.2

    License

    ISC

    Last publish

    Collaborators

    • justmoon