File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " thirdweb " : patch
3+ ---
4+
5+ Improve destination tokens error handling
Original file line number Diff line number Diff line change 77 getPaySupportedSources ,
88} from "../../../../../../../pay/utils/definitions.js" ;
99import { getClientFetch } from "../../../../../../../utils/fetch.js" ;
10+ import { stringify } from "../../../../../../../utils/json.js" ;
1011import { withCache } from "../../../../../../../utils/promise/withCache.js" ;
1112
1213type Response = {
@@ -44,7 +45,16 @@ export async function fetchBuySupportedDestinations(
4445 const res = await fetchWithHeaders (
4546 `${ getPaySupportedDestinations ( ) } ${ isTestMode ? "?isTestMode=true" : "" } ` ,
4647 ) ;
48+ if ( ! res . ok ) {
49+ const error = await res . text ( ) ;
50+ throw new Error ( `Failed to fetch supported destinations: ${ error } ` ) ;
51+ }
4752 const data = ( await res . json ( ) ) as Response ;
53+ if ( ! data . result ) {
54+ throw new Error (
55+ `Failed to parse supported destinations: ${ data ? stringify ( data ) : undefined } ` ,
56+ ) ;
57+ }
4858 return data . result . map ( ( item ) => ( {
4959 chain : defineChain ( {
5060 id : item . chainId ,
You can’t perform that action at this time.
0 commit comments