Skip to content

Commit 20b5ba9

Browse files
[SDK] Propagate 401 errors when connecting in-app wallet (#7040)
1 parent f0f8da8 commit 20b5ba9

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

.changeset/six-dryers-sing.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Propagate 401 errors when connecting in-app wallet

packages/thirdweb/src/wallets/in-app/core/actions/get-enclave-user-status.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export async function getUserStatus({
1717
authToken: string;
1818
client: ThirdwebClient;
1919
ecosystem?: Ecosystem;
20-
}): Promise<UserStatus | undefined> {
20+
}): Promise<UserStatus> {
2121
const clientFetch = getClientFetch(client, ecosystem);
2222
const response = await clientFetch(
2323
`${getThirdwebBaseUrl("inAppWallet")}/api/2024-05-05/accounts`,
@@ -32,12 +32,10 @@ export async function getUserStatus({
3232
);
3333

3434
if (!response.ok) {
35-
if (response.status === 401) {
36-
// 401 response indicates there is no user logged in, so we return undefined
37-
return undefined;
38-
}
39-
const result = await response.json();
40-
throw new Error(`Failed to get user status: ${result.message}`);
35+
const result = await response.text().catch(() => {
36+
return "Unknown error";
37+
});
38+
throw new Error(`Failed to get user info: ${result}`);
4139
}
4240

4341
return (await response.json()) as UserStatus;

0 commit comments

Comments
 (0)