From faa1e844d89464d3237a2be30d7039d19ab2aa71 Mon Sep 17 00:00:00 2001 From: Aaron Choo Date: Wed, 3 Jul 2024 14:46:01 +0800 Subject: [PATCH] fix: wrap error messages correctly from walletconnect --- src/wallet/wallets/WalletError.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallets/WalletError.ts b/src/wallet/wallets/WalletError.ts index bada7cf5..8cf1bfe4 100644 --- a/src/wallet/wallets/WalletError.ts +++ b/src/wallet/wallets/WalletError.ts @@ -27,8 +27,11 @@ export class WalletError extends Error { if (typeof err === "string") { throw new WalletError(err, err); } - if (err instanceof Error) { - throw new WalletError(err.message, err); + if ( + err instanceof Error || + (typeof err === "object" && err != null && "message" in err) + ) { + throw new WalletError((err as Record<"message", string>).message, err); } throw new WalletError("unknown error", err); }