Skip to content

Commit

Permalink
Improve storage upload error handling (#4763)
Browse files Browse the repository at this point in the history
  • Loading branch information
jnsdls committed Sep 23, 2024
1 parent 57a0e27 commit 399ba2e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/thick-gifts-push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

improve error handling for 402 and 403 error codes in storage upload
10 changes: 10 additions & 0 deletions packages/thirdweb/src/storage/upload/web-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ export async function uploadBatch<const TFiles extends UploadableFile[]>(
"Unauthorized - You don't have permission to use this service.",
);
}
if (res.status === 402) {
throw new Error(
"You have reached your storage limit. Please add a valid payment method to continue using the service.",
);
}
if (res.status === 403) {
throw new Error(
"Forbidden - You don't have permission to use this service.",
);
}

Check warning on line 42 in packages/thirdweb/src/storage/upload/web-node.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/storage/upload/web-node.ts#L33-L42

Added lines #L33 - L42 were not covered by tests
throw new Error(
`Failed to upload files to IPFS - ${res.status} - ${res.statusText}`,
);
Expand Down

0 comments on commit 399ba2e

Please sign in to comment.