Skip to content

Commit 7d81355

Browse files
committed
Improve error handling
1 parent a867e88 commit 7d81355

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/app/conf/2025/schedule/[id]/page.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import clsx from "clsx"
66
import { metadata as layoutMetadata } from "@/app/conf/2023/layout"
77

88
import { speakers, schedule } from "../../_data"
9-
import { ScheduleSession } from "../../../2023/types"
9+
import { SchedSpeaker, ScheduleSession } from "../../../2023/types"
1010

1111
import { findVideo, SessionVideo } from "./session-video"
1212
import { NavbarPlaceholder } from "../../components/navbar"
@@ -55,10 +55,15 @@ export default function SessionPage({ params }: SessionProps) {
5555
notFound()
5656
}
5757

58-
// @ts-expect-error -- fixme
59-
session.speakers = (session.speakers || []).map(speaker =>
60-
speakers.find(s => s.username === speaker.username),
61-
)
58+
session.speakers = (session.speakers || []).map(speaker => {
59+
const found = speakers.find(s => s.username === speaker.username)
60+
if (!found) {
61+
throw new Error(
62+
`Speaker "${speaker.username}" not found for "${session.name}"`,
63+
)
64+
}
65+
return found
66+
})
6267

6368
const eventTitle = getEventTitle(
6469
session,

src/app/conf/_api/sched-data.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ export function readSpeakers(year: ConferenceYear): SchedSpeaker[] {
1717
}
1818

1919
// TODO: We need to be able to say that a speaker is returning even if they don't share username, only first name and last name.
20-
// But this needs to be done without adding to `~years` so we don't show duplicates.
20+
// But this needs to be done without adding to `_years` so we don't show duplicates.

0 commit comments

Comments
 (0)