create-error-class
Advanced tools
Comparing version 2.0.1 to 3.0.0
18
index.js
'use strict'; | ||
var inherits = require('inherits'); | ||
var captureStackTrace = require('capture-stack-trace'); | ||
function inherits(ctor, superCtor) { | ||
ctor.super_ = superCtor; | ||
ctor.prototype = Object.create(superCtor.prototype, { | ||
constructor: { | ||
value: ctor, | ||
enumerable: false, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
} | ||
module.exports = function createErrorClass(className, setup) { | ||
@@ -15,3 +25,5 @@ if (typeof className !== 'string') { | ||
setup = setup || function () {}; | ||
setup = setup || function (message) { | ||
this.message = message; | ||
}; | ||
@@ -18,0 +30,0 @@ /* jshint evil:true */ |
{ | ||
"name": "create-error-class", | ||
"version": "2.0.1", | ||
"version": "3.0.0", | ||
"description": "Create Error classes", | ||
@@ -25,4 +25,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"capture-stack-trace": "^1.0.0", | ||
"inherits": "^2.0.1" | ||
"capture-stack-trace": "^1.0.0" | ||
}, | ||
@@ -29,0 +28,0 @@ "devDependencies": { |
@@ -37,3 +37,3 @@ # create-error-class [![Build Status](https://travis-ci.org/floatdrop/create-error-class.svg?branch=master)](https://travis-ci.org/floatdrop/create-error-class) | ||
Class name of Error Object. Should contain characters, validated by this regex: `[^0-9a-zA-Z_$]`. | ||
Class name of Error Object. Should contain characters from `[0-9a-zA-Z_$]` range. | ||
@@ -45,4 +45,12 @@ #### setup | ||
By default `setup` function sets `this.message` as first argument: | ||
```js | ||
var MyError = createErrorClass('MyError'); | ||
new MyError('Something gone wrong!').message; // => 'Something gone wrong!' | ||
``` | ||
## License | ||
MIT © [Vsevolod Strukchinsky](http://github.com/floatdrop) |
3694
1
4
29
55
- Removedinherits@^2.0.1
- Removedinherits@2.0.4(transitive)