This commit is contained in:
Josh Harvey 2016-05-04 18:34:12 +01:00
parent 95fa296190
commit cd1e9bdb66
4 changed files with 57 additions and 10 deletions

19
lib/error.js Normal file
View file

@ -0,0 +1,19 @@
const E = function generateError (name) {
var CustomErr = function (msg) {
this.message = msg
this.name = name
Error.captureStackTrace(this, CustomErr)
}
CustomErr.prototype = Object.create(Error.prototype)
CustomErr.prototype.constructor = CustomErr
return CustomErr
}
module.exports = E
function register (errorName) {
E[errorName] = E(errorName)
}
register('BadNumberError')