From 377ac04c856bf714087d437c72b32508bb7d49ba Mon Sep 17 00:00:00 2001 From: ekzyis Date: Wed, 3 Jul 2024 02:50:51 +0200 Subject: [PATCH] Use same error format in toast and wallet log --- api/resolvers/wallet.js | 8 ++++---- components/wallet/index.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api/resolvers/wallet.js b/api/resolvers/wallet.js index c3485efd..8b1c1331 100644 --- a/api/resolvers/wallet.js +++ b/api/resolvers/wallet.js @@ -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' } }) } } diff --git a/components/wallet/index.js b/components/wallet/index.js index 9f5ae7a4..c2d2c4dc 100644 --- a/components/wallet/index.js +++ b/components/wallet/index.js @@ -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])