Socket
Socket
Sign inDemoInstall

create-error-class

Package Overview
Dependencies
1
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    create-error-class

Create Error classes


Version published
Maintainers
1
Install size
8.85 kB
Created

Readme

Source

create-error-class Build Status

Create error class

Install

$ npm install --save create-error-class

Usage

var createErrorClass = require('create-error-class');

var HTTPError = createErrorClass('HTTPError', function () {
	this.message = 'Status code is ' + this.statusCode;
});

throw new HTTPError({statusCode: 404});

API

createErrorClass(className, [constructor])

Return constructor of Errors with className. Constructor accepts optional message and props, that will be assigned to Error.

className

Required
Type: string

Class name of Error Object.

constructor

Type: function

Function, that will be called after each Error object is created from constructor with context of Error object.

License

MIT © Vsevolod Strukchinsky

FAQs

Last updated on 19 Jul 2015

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