From fee5f4d0453ec9c8bd57f1d64ae2abee2b316783 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 5 Apr 2018 03:29:37 +0000 Subject: nicer error messages --- index.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index d6278dae..ac91bada 100644 --- a/index.js +++ b/index.js @@ -234,13 +234,19 @@ const l = console.log channel.on('error', err => { l('channel error', peer, err) - if (err.message.startsWith('Multiple')) { + let msg = err.message + + if (msg.startsWith('Multiple')) { busypeers.push(peer) peer = lna.channelpeers.find(p => !busypeers.includes(p)) return openchannel(peer, amount) } - return res.status(500).send(err.message) + if (msg.startsWith('not enough')) { + msg = 'Server wallet is busy. Wait for a block and try again' + } + + return res.status(500).send(msg) }) } @@ -307,7 +313,9 @@ const l = console.log }) stream.on('error', e => { - res.status(500).send(e.message) + let msg = e.message + + res.status(500).send(msg) }) }) @@ -353,7 +361,13 @@ const l = console.log res.send({ txid, tx, amount, fees }) } catch (e) { l(e) - res.status(500).send(e.message) + let msg = e.message + + if (msg.startsWith('insufficient')) { + msg = 'Server wallet is busy. Wait a block and try again' + } + + res.status(500).send(msg) } }) -- cgit v1.2.3