fix(smart-wallet): Improve error message for connection failures (#4343)

## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR improves error handling in smart wallet connection by providing a more informative error message when encountering an RPC error.

### Detailed summary
- Improved error message when smart wallet connection fails due to RPC error
- Added dynamic error message including original error message or "unknown error"

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
This commit is contained in:
joaquim-verges
2024-09-01 02:41:31 +00:00
parent 3dc675e69c
commit a2f2c7e172
2 changed files with 6 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---
Better error message when smart wallet connection fails due to rpc error
+1 -1
View File
@@ -133,7 +133,7 @@ export async function connectSmartWallet(
.then((address) => address)
.catch((err) => {
throw new Error(
`Failed to get account address with factory contract ${factoryContract.address} on chain ID ${chain.id}. Are you on the right chain?`,
`Failed to get account address with factory contract ${factoryContract.address} on chain ID ${chain.id}: ${err?.message || "unknown error"}`,
{ cause: err },
);
});