v12.0.0 - initial commit
This commit is contained in:
commit
e2c49ea43c
1145 changed files with 97211 additions and 0 deletions
27
packages/server/lib/error.js
Normal file
27
packages/server/lib/error.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
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')
|
||||
register('RatchetError')
|
||||
register('NotImplementedError')
|
||||
Loading…
Add table
Add a link
Reference in a new issue