feat: add error handling to player episode functions

This commit is contained in:
2026-06-16 14:00:35 +02:00
committed by Milas Holsting
parent 0cd47ab0fe
commit 3a1a2129d9
3 changed files with 9 additions and 4 deletions

View File

@@ -29,8 +29,9 @@ export const completeAnime = async (episodeNumber: number): Promise<void> => {
caret.textContent = "▾";
trigger.appendChild(caret);
}
} catch {
} catch (error) {
state.episode.completionSent = false;
console.error("failed to complete anime:", error);
if (state.episode.completionAttempts < 2) {
state.episode.completionAttempts++;
setTimeout(() => completeAnime(episodeNumber), 1000);

View File

@@ -93,7 +93,9 @@ export const goToNextEpisode = async (): Promise<void> => {
const nextSourceURL = `${state.playback.streamURL}?mode=${encodeURIComponent(fallback)}&token=${encodeURIComponent(source.token)}${source.type === "m3u8" ? "&hls=1" : ""}${preferredQuality !== "best" ? `&quality=${encodeURIComponent(preferredQuality)}` : ""}`;
loadVideoSource(nextSourceURL, source.type);
if (!state.elements.video.paused) {
state.elements.video.play().catch(() => undefined);
state.elements.video.play().catch((error) => {
console.debug("failed to play video:", error);
});
}
state.playback.pendingSeekTime = null;
@@ -137,7 +139,8 @@ export const goToNextEpisode = async (): Promise<void> => {
const url = new URL(window.location.href);
url.searchParams.set("ep", String(nextEp));
history.pushState(null, "", url.toString());
} catch {
} catch (error) {
console.error("failed to update url:", error);
fallbackToEpisodeNavigation(nextEp);
}
};

View File

@@ -43,7 +43,8 @@ export const setupThumbnails = (): void => {
}
});
})
.catch(() => {
.catch((error) => {
window.showToast?.({ message: "Failed to load episode thumbnails." });
console.error("failed to load episode thumbnails:", error);
});
};