Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/twenty-cows-take.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Better error message for getUser
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,17 @@ describe("getUser", () => {
it("should handle fetch errors", async () => {
mockFetch.mockResolvedValueOnce({
ok: false,
status: 404,
statusText: "Not Found",
text: async () => "some message",
});

await expect(
getUser({
client: mockClient,
walletAddress: "0x123",
}),
).rejects.toThrow("Failed to get profiles");
).rejects.toThrow("Failed to get profiles. 404 Not Found: some message");
});

it("should return null if no user is found", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ export async function getUser({
const res = await clientFetch(url.toString());

if (!res.ok) {
throw new Error("Failed to get profiles");
const error = await res.text().catch(() => "Unknown error");
throw new Error(
`Failed to get profiles. ${res.status} ${res.statusText}: ${error}`,
);
}

const data = (await res.json()) as {
Expand Down
Loading