From 056a993831c45991c127173b5471df7b53ef2bd7 Mon Sep 17 00:00:00 2001 From: homura Date: Fri, 26 Jul 2024 15:40:41 +0900 Subject: [PATCH] refactor: pretty error message --- .../src/services/hardware/ledger.ts | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/neuron-wallet/src/services/hardware/ledger.ts b/packages/neuron-wallet/src/services/hardware/ledger.ts index 811a6f4ec..d82657383 100644 --- a/packages/neuron-wallet/src/services/hardware/ledger.ts +++ b/packages/neuron-wallet/src/services/hardware/ledger.ts @@ -81,20 +81,20 @@ export default class Ledger extends Hardware { const hdPath = path === hd.AccountExtendedPublicKey.pathForReceiving(0) ? this.defaultPath : path const signature = await this.ledgerCKB!.signTransaction(hdPath, rawTx, witnesses, context, this.defaultPath).catch( error => { - if (error instanceof Error) { - logger.error( - 'Ledger: failed to sign the transaction', - error.message, - ' HD path:', - hdPath, - ' raw transaction:', - JSON.stringify(rawTx), - ' witnesses:', - JSON.stringify(witnesses), - ' context:', - JSON.stringify(context) - ) - } + const errorMessage = error instanceof Error ? error.message : String(error) + logger.error( + 'Ledger: failed to sign the transaction ', + errorMessage, + ' HD path:', + hdPath, + ' raw transaction:', + JSON.stringify(rawTx), + ' witnesses:', + JSON.stringify(witnesses), + ' context:', + JSON.stringify(context) + ) + return Promise.reject(error) } )