This commit is contained in:
Overtorment 2020-01-25 15:41:49 +00:00
parent 03ddddbf6a
commit 14d42a7aed
2 changed files with 6 additions and 10 deletions

View File

@ -128,14 +128,14 @@ router.post('/payinvoice', async function(req, res) {
// obtaining a lock // obtaining a lock
let lock = new Lock(redis, 'invoice_paying_for_' + u.getUserId()); let lock = new Lock(redis, 'invoice_paying_for_' + u.getUserId());
if (!(await lock.obtainLock())) { if (!(await lock.obtainLock())) {
return errorTryAgainLater(res); return errorGeneralServerError(res);
} }
let userBalance; let userBalance;
try { try {
userBalance = await u.getCalculatedBalance(); userBalance = await u.getCalculatedBalance();
} catch (Error) { } catch (Error) {
logger.log('', [req.id, 'error running getCalculatedBalance():', Error]); logger.log('', [req.id, 'error running getCalculatedBalance():', Error.message]);
lock.releaseLock(); lock.releaseLock();
return errorTryAgainLater(res); return errorTryAgainLater(res);
} }
@ -269,7 +269,7 @@ router.get('/balance', postLimiter, async function(req, res) {
if (balance < 0) balance = 0; if (balance < 0) balance = 0;
res.send({ BTC: { AvailableBalance: balance } }); res.send({ BTC: { AvailableBalance: balance } });
} catch (Error) { } catch (Error) {
logger.log('', [req.id, 'error:', Error]); logger.log('', [req.id, 'error getting balance:', Error.message, 'userid:', u.getUserId()]);
return errorGeneralServerError(res); return errorGeneralServerError(res);
} }
}); });
@ -310,7 +310,7 @@ router.get('/gettxs', async function(req, res) {
} }
res.send(txs); res.send(txs);
} catch (Err) { } catch (Err) {
logger.log('', [req.id, 'error:', Err]); logger.log('', [req.id, 'error gettxs:', Err.message, 'userid:', u.getUserId()]);
res.send([]); res.send([]);
} }
}); });
@ -330,7 +330,7 @@ router.get('/getuserinvoices', async function(req, res) {
res.send(invoices); res.send(invoices);
} }
} catch (Err) { } catch (Err) {
logger.log('', [req.id, 'error:', Err]); logger.log('', [req.id, 'error getting user invoices:', Err.message, 'userid:', u.getUserId()]);
res.send([]); res.send([]);
} }
}); });
@ -420,7 +420,7 @@ function errorGeneralServerError(res) {
return res.send({ return res.send({
error: true, error: true,
code: 6, code: 6,
message: 'Server fault', message: 'Something went wrong. Please try again later',
}); });
} }

View File

@ -37,10 +37,6 @@ if (!fs.existsSync('logs')) {
fs.mkdirSync('logs'); fs.mkdirSync('logs');
} }
/**
* @param {string} label group label
* @param {string} message log message
*/
function log(label, message) { function log(label, message) {
logger.log({ logger.log({
level: 'info', level: 'info',