WIP
This commit is contained in:
parent
95fa296190
commit
cd1e9bdb66
4 changed files with 57 additions and 10 deletions
19
lib/error.js
Normal file
19
lib/error.js
Normal 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')
|
||||
Loading…
Add table
Add a link
Reference in a new issue