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,22 +42,43 @@ export async function resolveF1tvPlay(
|
||||||
const preferredChannel =
|
const preferredChannel =
|
||||||
opts?.channelId ?? session?.defaultChannelId ?? 1033;
|
opts?.channelId ?? session?.defaultChannelId ?? 1033;
|
||||||
|
|
||||||
const played = await fetchContentPlay({
|
let played: Awaited<ReturnType<typeof fetchContentPlay>>;
|
||||||
contentId,
|
try {
|
||||||
channelId: preferredChannel,
|
played = await fetchContentPlay({
|
||||||
auth: {
|
contentId,
|
||||||
ascendontoken: account.ascendontoken,
|
channelId: preferredChannel,
|
||||||
entitlementtoken: account.entitlementtoken,
|
auth: {
|
||||||
sessionId: ensureSessionId(account.sessionId),
|
ascendontoken: account.ascendontoken,
|
||||||
},
|
entitlementtoken: account.entitlementtoken,
|
||||||
locale: config.locale,
|
sessionId: ensureSessionId(account.sessionId),
|
||||||
playPlatform: "WEB_HLS",
|
},
|
||||||
timeoutMs: config.syncTimeoutMs,
|
locale: config.locale,
|
||||||
});
|
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);
|
const feed = pickDefaultFeed(played.feeds, preferredChannel);
|
||||||
if (!feed?.url) {
|
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 {
|
return {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue