Skip to content

Commit 3489ece

Browse files
[SDK] Improve quote error handling (#7147)
1 parent f9b34ff commit 3489ece

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

.changeset/tall-walls-juggle.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+
Better Quote errors

packages/thirdweb/src/bridge/types/Errors.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ type ErrorCode =
33
| "ROUTE_NOT_FOUND"
44
| "AMOUNT_TOO_LOW"
55
| "AMOUNT_TOO_HIGH"
6+
| "INTERNAL_SERVER_ERROR"
67
| "UNKNOWN_ERROR";
78

89
export class ApiError extends Error {

packages/thirdweb/src/react/web/utils/errors.ts

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,20 @@ type UiError = {
99
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
1010
export function getErrorMessage(err: any): UiError {
1111
if (err instanceof ApiError) {
12+
if (err.code === "INTERNAL_SERVER_ERROR") {
13+
return {
14+
code: "INTERNAL_SERVER_ERROR",
15+
title: "Failed to Find Quote",
16+
message: "An unknown error occurred. Please try again.",
17+
};
18+
}
1219
return {
1320
code: err.code,
1421
title: "Failed to Find Quote",
1522
message: getErrorMessageFromBridgeApiError(err),
1623
};
1724
}
1825

19-
if (typeof err.error === "object" && err.error.code) {
20-
if (err.error.code === "MINIMUM_PURCHASE_AMOUNT") {
21-
return {
22-
code: "MINIMUM_PURCHASE_AMOUNT",
23-
title: "Amount Too Low",
24-
message:
25-
"The requested amount is less than the minimum purchase. Try another provider or amount.",
26-
};
27-
}
28-
}
29-
30-
console.error(err);
31-
3226
return {
3327
code: "UNABLE_TO_GET_PRICE_QUOTE",
3428
title: "Failed to Find Quote",

0 commit comments

Comments
 (0)