1 # create-error-class [![Build Status](https://travis-ci.org/floatdrop/create-error-class.svg?branch=master)](https://travis-ci.org/floatdrop/create-error-class)
9 $ npm install --save create-error-class
16 var createErrorClass = require('create-error-class');
18 var HTTPError = createErrorClass('HTTPError', function (props) {
19 this.message = 'Status code is ' + props.statusCode;
22 throw new HTTPError({statusCode: 404});
28 ### createErrorClass(className, [setup])
30 Return constructor of Errors with `className`.
37 Class name of Error Object. Should contain characters from `[0-9a-zA-Z_$]` range.
42 Setup function, that will be called after each Error object is created from constructor with context of Error object.
44 By default `setup` function sets `this.message` as first argument:
47 var MyError = createErrorClass('MyError');
49 new MyError('Something gone wrong!').message; // => 'Something gone wrong!'
54 MIT © [Vsevolod Strukchinsky](http://github.com/floatdrop)