handle cash-in errors
This commit is contained in:
parent
48dd23c11d
commit
86adfd0a63
7 changed files with 40 additions and 24 deletions
|
|
@ -15,6 +15,7 @@ const plugins = require('./plugins')
|
|||
const helpers = require('./route-helpers')
|
||||
const poller = require('./poller')
|
||||
const Tx = require('./tx')
|
||||
const E = require('./error')
|
||||
|
||||
const argv = require('minimist')(process.argv.slice(2))
|
||||
|
||||
|
|
@ -102,7 +103,17 @@ function postTx (req, res, next) {
|
|||
const pi = plugins(req.settings, req.deviceId)
|
||||
|
||||
return Tx.post(_.set('deviceId', req.deviceId, req.body), pi)
|
||||
.then(tx => res.json(tx))
|
||||
.then(tx => {
|
||||
if (tx.errorCode) {
|
||||
console.log('DEBUG100: %s, %s', tx.errorCode, E.InsufficientFundsError.name)
|
||||
if (tx.errorCode === E.InsufficientFundsError.code) {
|
||||
throw httpError(tx.error, 570)
|
||||
}
|
||||
throw httpError(tx.error, 500)
|
||||
}
|
||||
|
||||
return res.json(tx)
|
||||
})
|
||||
.catch(next)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue