Map F1TV play failures to clear AppErrors instead of INTERNAL_ERROR.
Upcoming agenda sessions were hitting CONTENT/PLAY and surfacing a generic 500 to the TV app.
This commit is contained in:
parent
20a3cfb056
commit
9ac832545d
1 changed files with 34 additions and 13 deletions
|
|
@ -42,7 +42,9 @@ export async function resolveF1tvPlay(
|
|||
const preferredChannel =
|
||||
opts?.channelId ?? session?.defaultChannelId ?? 1033;
|
||||
|
||||
const played = await fetchContentPlay({
|
||||
let played: Awaited<ReturnType<typeof fetchContentPlay>>;
|
||||
try {
|
||||
played = await fetchContentPlay({
|
||||
contentId,
|
||||
channelId: preferredChannel,
|
||||
auth: {
|
||||
|
|
@ -54,10 +56,29 @@ export async function resolveF1tvPlay(
|
|||
playPlatform: "WEB_HLS",
|
||||
timeoutMs: config.syncTimeoutMs,
|
||||
});
|
||||
} catch (err) {
|
||||
const msg = err instanceof Error ? err.message : String(err);
|
||||
if (/HTTP 4\d\d|NOT_FOUND|UNAVAILABLE|FORBIDDEN/i.test(msg)) {
|
||||
throw new AppError(
|
||||
"NOT_READY",
|
||||
session?.kind === "live_event" && session.startMs > Date.now()
|
||||
? "Dit event is nog niet begonnen"
|
||||
: "F1TV-stream is nu niet beschikbaar",
|
||||
409
|
||||
);
|
||||
}
|
||||
throw new AppError("UPSTREAM_ERROR", `F1TV play mislukt: ${msg.slice(0, 160)}`, 502);
|
||||
}
|
||||
|
||||
const feed = pickDefaultFeed(played.feeds, preferredChannel);
|
||||
if (!feed?.url) {
|
||||
throw new AppError("NOT_READY", "Geen F1TV-stream-URL ontvangen", 409);
|
||||
throw new AppError(
|
||||
"NOT_READY",
|
||||
session?.kind === "live_event" && session.startMs > Date.now()
|
||||
? "Dit event is nog niet begonnen"
|
||||
: "Geen F1TV-stream-URL ontvangen",
|
||||
409
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
|||
Loading…
Reference in a new issue