improve cash-in error handling
This commit is contained in:
parent
86adfd0a63
commit
84a93599f5
9 changed files with 263 additions and 47 deletions
|
|
@ -15,7 +15,6 @@ 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))
|
||||
|
||||
|
|
@ -104,14 +103,7 @@ function postTx (req, res, next) {
|
|||
|
||||
return Tx.post(_.set('deviceId', req.deviceId, req.body), pi)
|
||||
.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)
|
||||
}
|
||||
|
||||
if (tx.errorCode) throw httpError(tx.error, 500)
|
||||
return res.json(tx)
|
||||
})
|
||||
.catch(next)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue