Skip to content

Commit 399ba2e

Browse files
committed
Improve storage upload error handling (#4763)
1 parent 57a0e27 commit 399ba2e

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

.changeset/thick-gifts-push.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+
improve error handling for 402 and 403 error codes in storage upload

packages/thirdweb/src/storage/upload/web-node.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ export async function uploadBatch<const TFiles extends UploadableFile[]>(
3030
"Unauthorized - You don't have permission to use this service.",
3131
);
3232
}
33+
if (res.status === 402) {
34+
throw new Error(
35+
"You have reached your storage limit. Please add a valid payment method to continue using the service.",
36+
);
37+
}
38+
if (res.status === 403) {
39+
throw new Error(
40+
"Forbidden - You don't have permission to use this service.",
41+
);
42+
}
3343
throw new Error(
3444
`Failed to upload files to IPFS - ${res.status} - ${res.statusText}`,
3545
);

0 commit comments

Comments
 (0)