Skip to content

Commit 1642396

Browse files
authored
Merge pull request #15828 from ethereum/fix-stablecoins-table
fix: handle missing CoinGecko stablecoin data gracefully
2 parents d1012d4 + 42c881a commit 1642396

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

app/[locale]/stablecoins/page.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,16 @@ async function Page({ params }: { params: Promise<{ locale: Lang }> }) {
115115
const ethereumStablecoinData = stablecoins
116116
.map(({ id, ...rest }) => {
117117
const coinMarketData = stablecoinsData.find((coin) => coin.id === id)
118-
if (!coinMarketData)
119-
throw new Error("CoinGecko stablecoin data not found:" + id)
118+
if (!coinMarketData) {
119+
console.warn("CoinGecko stablecoin data not found:", id)
120+
return null
121+
}
120122
return { ...coinMarketData, ...rest }
121123
})
122-
.filter((coin) => coin.market_cap >= MIN_MARKET_CAP_USD)
124+
.filter(
125+
(coin): coin is Exclude<typeof coin, null> =>
126+
coin !== null && coin.market_cap >= MIN_MARKET_CAP_USD
127+
)
123128
.sort((a, b) => b.market_cap - a.market_cap)
124129
.map(({ market_cap, ...rest }) => ({
125130
...rest,

0 commit comments

Comments
 (0)