diff --git a/packages/web-components/src/wallet-connection/walletConnection.js b/packages/web-components/src/wallet-connection/walletConnection.js index 2fe1760..557500f 100644 --- a/packages/web-components/src/wallet-connection/walletConnection.js +++ b/packages/web-components/src/wallet-connection/walletConnection.js @@ -8,7 +8,7 @@ import { Errors } from '../errors.js'; /** * @param {any} chainStorageWatcher * @param {string} rpc - * @param {((error: unknown) => void)=} onRpcError + * @param {((error: unknown) => void)} [onRpcError] */ export const makeAgoricWalletConnection = async ( chainStorageWatcher, diff --git a/packages/web-components/src/wallet-connection/watchWallet.js b/packages/web-components/src/wallet-connection/watchWallet.js index 6078e58..7894649 100644 --- a/packages/web-components/src/wallet-connection/watchWallet.js +++ b/packages/web-components/src/wallet-connection/watchWallet.js @@ -38,7 +38,7 @@ const MAX_ATTEMPTS_TO_WATCH_BANK = 2; * @param {any} chainStorageWatcher * @param {string} address * @param {string} rpc - * @param {((error: unknown) => void)=} onRpcError + * @param {((error: unknown) => void)} [onRpcError] */ export const watchWallet = (chainStorageWatcher, address, rpc, onRpcError) => { const pursesNotifierKit = makeNotifierKit( @@ -140,7 +140,10 @@ export const watchWallet = (chainStorageWatcher, address, rpc, onRpcError) => { } catch (e) { console.error('Error querying bank balances for address', address); if (attempts >= MAX_ATTEMPTS_TO_WATCH_BANK) { - onRpcError && onRpcError(e); + onRpcError && + onRpcError( + new Error(`RPC error${e.toString && ` - ${e.toString()}`}`), + ); } else { setTimeout(() => watchBank(attempts + 1), RETRY_INTERVAL_MS); return; @@ -222,7 +225,10 @@ export const watchWallet = (chainStorageWatcher, address, rpc, onRpcError) => { ); } catch (e) { console.error('Error getting boardAux for brands', brands, e); - onRpcError && onRpcError(e); + onRpcError && + onRpcError( + new Error(`API error${e.toString && ` - ${e.toString()}`}`), + ); } } @@ -256,7 +262,8 @@ export const watchWallet = (chainStorageWatcher, address, rpc, onRpcError) => { try { await watch(); } catch (e) { - onRpcError && onRpcError(e); + onRpcError && + onRpcError(new Error(`RPC error${e.toString && ` - ${e.toString()}`}`)); } };