catch errors
This commit is contained in:
parent
71c239d432
commit
288ba30a16
1 changed files with 26 additions and 16 deletions
|
|
@ -3086,22 +3086,32 @@ module.exports = async (
|
||||||
})
|
})
|
||||||
|
|
||||||
ap.post('/api/lnd/cb/:methodName', (req, res) => {
|
ap.post('/api/lnd/cb/:methodName', (req, res) => {
|
||||||
const { lightning } = LightningServices.services
|
try {
|
||||||
const { methodName } = req.params
|
const { lightning } = LightningServices.services
|
||||||
const args = req.body
|
const { methodName } = req.params
|
||||||
|
const args = req.body
|
||||||
|
|
||||||
lightning[methodName](args, (err, lres) => {
|
lightning[methodName](args, (err, lres) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
res.status(500).json({
|
res.status(500).json({
|
||||||
errorMessage: err.details
|
errorMessage: err.details
|
||||||
})
|
})
|
||||||
} else if (lres) {
|
} else if (lres) {
|
||||||
res.status(200).json(lres)
|
res.status(200).json(lres)
|
||||||
} else {
|
} else {
|
||||||
res.status(500).json({
|
res.status(500).json({
|
||||||
errorMessage: 'Unknown error'
|
errorMessage: 'Unknown error'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
} catch (err) {
|
||||||
|
logger.warn(`Error inside api cb:`)
|
||||||
|
logger.error(err)
|
||||||
|
logger.error(err.message)
|
||||||
|
|
||||||
|
return res.status(500).json({
|
||||||
|
errorMessage: err.message
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue