fix: handle errors when wallet is unreachable
This commit is contained in:
parent
209bc1fabe
commit
145a21cc8d
2 changed files with 25 additions and 16 deletions
|
|
@ -48,18 +48,21 @@ function split (str) {
|
|||
}
|
||||
|
||||
function parseConf (confPath) {
|
||||
const conf = fs.readFileSync(confPath)
|
||||
const lines = conf.toString().split('\n')
|
||||
try {
|
||||
const conf = fs.readFileSync(confPath)
|
||||
const lines = conf.toString().split('\n')
|
||||
|
||||
const res = {}
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const keyVal = split(lines[i])
|
||||
const res = {}
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const keyVal = split(lines[i])
|
||||
|
||||
// skip when value is empty
|
||||
if (!keyVal[1]) continue
|
||||
// skip when value is empty
|
||||
if (!keyVal[1]) continue
|
||||
|
||||
res[keyVal[0]] = keyVal[1]
|
||||
res[keyVal[0]] = keyVal[1]
|
||||
}
|
||||
return res
|
||||
} catch (e) {
|
||||
throw new Error('wallet is currently not installed')
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue