feat: add error handling to player core functions

This commit is contained in:
2026-06-16 14:00:38 +02:00
committed by Milas Holsting
parent 3a1a2129d9
commit 2a8294c405
9 changed files with 45 additions and 22 deletions

View File

@@ -204,7 +204,8 @@ export const initState = (c: HTMLElement): boolean => {
const safeJsonUnknown = (raw: string | undefined): unknown => {
try {
return JSON.parse(raw ?? "");
} catch {
} catch (error) {
console.error("failed to parse json:", error);
return null;
}
};
@@ -237,7 +238,8 @@ export const initState = (c: HTMLElement): boolean => {
const modeParam = u.searchParams.get("mode");
if (modeParam === "sub" || modeParam === "dub") return modeParam;
return null;
} catch {
} catch (error) {
console.error("failed to parse mode url:", error);
return null;
}
};