Skip to content

Extendable Error Class for use with Node >= 4.x

License

Notifications You must be signed in to change notification settings

ahmadnassri/node-error

Repository files navigation

Extendable Error

Extendable Error Class for use with Node.js

license release semantic

Install

npm install @ahmadnassri/error

Usage

const ExtendableError = require('@ahmadnassri/error')

class MyError extends ExtendableError {
  // constructor is optionaly useful for adding custom arguments, or methods:
  constructor (code, message, extra) {
    super(message)

    this.code = code
    this.extra = extra
  }

  getCode () {
    return this.code
  }
}

Author: Ahmad Nassri • Twitter: @AhmadNassri