handle cash-in errors

This commit is contained in:
Josh Harvey 2017-04-23 13:44:36 +03:00
parent 48dd23c11d
commit 86adfd0a63
7 changed files with 40 additions and 24 deletions

View file

@ -1,11 +1,14 @@
const E = function generateError (name) {
const _ = require('lodash/fp')
const E = function (name) {
var CustomErr = function (msg) {
this.message = msg
this.message = msg || _.startCase(name)
this.name = name
Error.captureStackTrace(this, CustomErr)
}
CustomErr.prototype = Object.create(Error.prototype)
CustomErr.prototype.constructor = CustomErr
CustomErr.code = name
return CustomErr
}
@ -18,3 +21,4 @@ function register (errorName) {
register('BadNumberError')
register('NoDataError')
register('InsufficientFundsError')