Use same error format in toast and wallet log

This commit is contained in:
ekzyis 2024-07-03 02:50:51 +02:00
parent 9228328d3b
commit 377ac04c85
2 changed files with 5 additions and 5 deletions

View File

@ -452,8 +452,7 @@ export default {
} catch (err) {
// LND errors are in this shape: [code, type, { err: { code, details, metadata } }]
const details = err[2]?.err?.details || err.message || err.toString?.()
await addWalletLog({ wallet, level: 'ERROR', message: `could not connect to LND: ${details}` }, { me, models })
throw err
throw new Error(details)
}
}
},
@ -620,8 +619,9 @@ async function upsertWallet (
await testConnect(data)
} catch (err) {
console.error(err)
await addWalletLog({ wallet, level: 'ERROR', message: 'failed to attach wallet' }, { me, models })
throw new GraphQLError('failed to connect to wallet', { extensions: { code: 'BAD_INPUT' } })
const message = err.message || err.toString?.()
await addWalletLog({ wallet, level: 'ERROR', message: 'failed to attach: ' + message }, { me, models })
throw new GraphQLError(message, { extensions: { code: 'BAD_INPUT' } })
}
}

View File

@ -64,7 +64,7 @@ export function useWallet (name) {
logger.ok('wallet attached')
} catch (err) {
const message = err.message || err.toString?.()
logger.error(message)
logger.error('failed to attach: ' + message)
throw err
}
}, [saveConfig, me, logger])