lamassu-server/lib/error.js

25 lines
553 B
JavaScript

const _ = require('lodash/fp')
const E = function (name) {
var CustomErr = function (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
}
module.exports = E
function register (errorName) {
E[errorName] = E(errorName)
}
register('BadNumberError')
register('NoDataError')
register('InsufficientFundsError')
register('StaleTxError')