From 6aca242f9b71c2424195b3f01380e8f5e0915d43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Salgado?= Date: Wed, 25 May 2022 19:26:31 +0100 Subject: [PATCH] fix: node fetching error handling --- lib/plugins/common/json-rpc.js | 6 +++++- lib/plugins/wallet/monerod/monerod.js | 9 +++++++-- new-lamassu-admin/src/pages/Funding.js | 9 ++++++++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/plugins/common/json-rpc.js b/lib/plugins/common/json-rpc.js index 50372116..43163200 100644 --- a/lib/plugins/common/json-rpc.js +++ b/lib/plugins/common/json-rpc.js @@ -7,6 +7,7 @@ const request = require('request-promise') const { utils: coinUtils } = require('@lamassu/coins') const options = require('../../options') +const logger = require('../../logger') const blockchainDir = options.blockchainDir @@ -116,6 +117,9 @@ function rpcConfig (cryptoRec) { port: config.rpcport || cryptoRec.defaultPort } } catch (err) { - throw new Error('Wallet is currently not installed') + logger.error('Wallet is currently not installed!') + return { + port: cryptoRec.defaultPort + } } } diff --git a/lib/plugins/wallet/monerod/monerod.js b/lib/plugins/wallet/monerod/monerod.js index 2bc4f58d..e70b32ad 100644 --- a/lib/plugins/wallet/monerod/monerod.js +++ b/lib/plugins/wallet/monerod/monerod.js @@ -6,7 +6,7 @@ const { default: PQueue } = require('p-queue') const BN = require('../../../bn') const E = require('../../../error') -const { logger } = require('../../../blockchain/common') +const logger = require('../../../logger') const options = require('../../../options') const jsonRpc = require('../../common/json-rpc') @@ -40,7 +40,12 @@ function rpcConfig () { port: cryptoRec.walletPort || cryptoRec.defaultPort } } catch (err) { - throw new Error('wallet is currently not installed') + logger.error('Wallet is currently not installed!') + return { + username: '', + password: '', + port: cryptoRec.walletPort || cryptoRec.defaultPort + } } } diff --git a/new-lamassu-admin/src/pages/Funding.js b/new-lamassu-admin/src/pages/Funding.js index cf59519f..13f2a6c8 100644 --- a/new-lamassu-admin/src/pages/Funding.js +++ b/new-lamassu-admin/src/pages/Funding.js @@ -26,6 +26,9 @@ import { primaryColor } from 'src/styling/variables' import styles from './Funding.styles' +const NODE_NOT_CONNECTED_ERR = + "Couldn't establish connection with the node. Make sure it is installed and try again" + const useStyles = makeStyles(styles) const sizes = { big: 165, @@ -176,7 +179,11 @@ const Funding = () => { {selected && !viewHistory && selected.errorMsg && (
- {selected.errorMsg} + + {R.includes('ECONNREFUSED', selected.errorMsg) + ? NODE_NOT_CONNECTED_ERR + : selected.errorMsg} +
)}