diff --git a/.changeset/tall-walls-juggle.md b/.changeset/tall-walls-juggle.md new file mode 100644 index 00000000000..6d2e35e2d45 --- /dev/null +++ b/.changeset/tall-walls-juggle.md @@ -0,0 +1,5 @@ +--- +"thirdweb": patch +--- + +Better Quote errors diff --git a/packages/thirdweb/src/bridge/types/Errors.ts b/packages/thirdweb/src/bridge/types/Errors.ts index 842c3915869..ffa8da23164 100644 --- a/packages/thirdweb/src/bridge/types/Errors.ts +++ b/packages/thirdweb/src/bridge/types/Errors.ts @@ -3,6 +3,7 @@ type ErrorCode = | "ROUTE_NOT_FOUND" | "AMOUNT_TOO_LOW" | "AMOUNT_TOO_HIGH" + | "INTERNAL_SERVER_ERROR" | "UNKNOWN_ERROR"; export class ApiError extends Error { diff --git a/packages/thirdweb/src/react/web/utils/errors.ts b/packages/thirdweb/src/react/web/utils/errors.ts index bb01643ef22..d308410b197 100644 --- a/packages/thirdweb/src/react/web/utils/errors.ts +++ b/packages/thirdweb/src/react/web/utils/errors.ts @@ -9,6 +9,13 @@ type UiError = { // biome-ignore lint/suspicious/noExplicitAny: export function getErrorMessage(err: any): UiError { if (err instanceof ApiError) { + if (err.code === "INTERNAL_SERVER_ERROR") { + return { + code: "INTERNAL_SERVER_ERROR", + title: "Failed to Find Quote", + message: "An unknown error occurred. Please try again.", + }; + } return { code: err.code, title: "Failed to Find Quote", @@ -16,19 +23,6 @@ export function getErrorMessage(err: any): UiError { }; } - if (typeof err.error === "object" && err.error.code) { - if (err.error.code === "MINIMUM_PURCHASE_AMOUNT") { - return { - code: "MINIMUM_PURCHASE_AMOUNT", - title: "Amount Too Low", - message: - "The requested amount is less than the minimum purchase. Try another provider or amount.", - }; - } - } - - console.error(err); - return { code: "UNABLE_TO_GET_PRICE_QUOTE", title: "Failed to Find Quote",