Skip to content

Commit 596ca39

Browse files
committed
error handling
1 parent 6014ce8 commit 596ca39

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

app/[locale]/10years/_components/TorchHistorySwiper.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { getAvatarImage, type TorchHolderEvent } from "@/lib/torch"
1616

1717
type TorchHistorySwiperProps = {
1818
holders: TorchHolderEvent[]
19-
currentHolderAddress: Address
19+
currentHolderAddress: Address | null
2020
}
2121

2222
const TorchHistorySwiper = ({

app/[locale]/10years/page.tsx

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import {
4848
getHolders,
4949
isAddressFiltered,
5050
isTorchBurned,
51+
TorchHolder,
5152
} from "@/lib/torch"
5253
import TenYearLogo from "@/public/images/10-year-anniversary/10-year-logo.png"
5354

@@ -101,13 +102,19 @@ const Page = async ({ params }: { params: Promise<{ locale: Lang }> }) => {
101102
{} as Record<string, (typeof allTorchHolders)[0]>
102103
)
103104

104-
const isBurned = await isTorchBurned()
105-
const currentHolderAddress = await getCurrentHolderAddress()
106-
const isFiltered = isAddressFiltered(currentHolderAddress)
107-
108-
const currentHolder = isFiltered
109-
? null
110-
: torchHolderMap[currentHolderAddress.toLowerCase()]
105+
let isBurned = false
106+
let currentHolder: TorchHolder | null = null
107+
try {
108+
isBurned = await isTorchBurned()
109+
const currentHolderAddress = await getCurrentHolderAddress()
110+
const isFiltered = isAddressFiltered(currentHolderAddress)
111+
112+
currentHolder = isFiltered
113+
? null
114+
: torchHolderMap[currentHolderAddress.toLowerCase()]
115+
} catch (error) {
116+
console.error("Error fetching torch data:", error)
117+
}
111118
const torchHolders = await getHolders(torchHolderMap)
112119

113120
return (
@@ -306,7 +313,7 @@ const Page = async ({ params }: { params: Promise<{ locale: Lang }> }) => {
306313

307314
<TorchHistorySwiper
308315
holders={torchHolders}
309-
currentHolderAddress={currentHolderAddress}
316+
currentHolderAddress={currentHolder?.address || null}
310317
/>
311318

312319
<div className="flex flex-col gap-12 px-16 pb-24 pt-12 text-body-inverse md:flex-row dark:text-body">

0 commit comments

Comments
 (0)