From b56064a7ba05c6629ccdac174e7b12b621788d65 Mon Sep 17 00:00:00 2001 From: Overtorment Date: Sat, 18 Jan 2020 13:39:55 +0000 Subject: [PATCH] error logging --- controllers/api.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/controllers/api.js b/controllers/api.js index e7c5855..8db0ba7 100644 --- a/controllers/api.js +++ b/controllers/api.js @@ -255,11 +255,16 @@ router.get('/balance', postLimiter, async function(req, res) { return errorBadAuth(res); } - if (!(await u.getAddress())) await u.generateAddress(); // onchain address needed further - await u.accountForPosibleTxids(); - let balance = await u.getBalance(); - if (balance < 0) balance = 0; - res.send({ BTC: { AvailableBalance: balance } }); + try { + if (!(await u.getAddress())) await u.generateAddress(); // onchain address needed further + await u.accountForPosibleTxids(); + let balance = await u.getBalance(); + if (balance < 0) balance = 0; + res.send({ BTC: { AvailableBalance: balance } }); + } catch (Error) { + logger.log('', [req.id, 'error:', Error]); + return errorGeneralServerError(res); + } }); router.get('/getinfo', postLimiter, async function(req, res) {