lamassu-server/lib/error.js
2016-05-11 14:10:46 +03:00

20 lines
430 B
JavaScript

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')
register('NoDataError')