Files
SubMiner/src/animeui/error-message.ts
T
sudacode ca40cd6267 fix(anime): clarify bridge failures and update guidance
- Show actionable bridge errors and preserve episodes when details fail
- Check external bridges for updates without offering unsafe in-app installs
- Complete cleanup and ignore callbacks from closed Tsukihime sessions
2026-09-16 23:25:21 -07:00

72 lines
2.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
export interface AnimeBrowserErrorMessage {
title: string;
explanation: string;
guidance: string;
details: string;
}
const OPERATIONS: Record<string, string> = {
getDetailsAnime: 'Could not load anime details',
getEpisodeList: 'Could not load episodes',
getVideoList: 'Could not resolve the video',
getSearchAnime: 'Could not search this source',
getPopularAnime: 'Could not browse this source',
};
/** Error messages survive both Electron IPC and the embedded browser's transport. */
export function describeAnimeBrowserError(message: string): AnimeBrowserErrorMessage {
const bridge = /Anime bridge (\w+) failed(?: \(\d+\))?[.:]/.exec(message);
const operation = bridge?.[1];
const title = (operation && OPERATIONS[operation]) || 'Request failed';
const details = message;
if (
bridge &&
/NoSuchMethodError|NoClassDefFoundError|AbstractMethodError|(?:java\.lang\.Object|void|boolean) eu\.kanade\.[\w.$]+\(/.test(
message,
)
) {
return {
title,
explanation:
'This extension needs functionality that the installed extension bridge does not provide.',
guidance:
'Check Extensions for bridge updates. If none are available, try another source and include the technical details when reporting the issue.',
details,
};
}
if (bridge && /lateinit property \w+ has not been initialized/.test(message)) {
return {
title,
explanation:
'The extension bridge could not read a required field from the extensions data.',
guidance:
'Check Extensions for extension and bridge updates. If this continues, try another source and include the technical details when reporting the issue.',
details,
};
}
if (bridge) {
return {
title,
explanation: 'The extension bridge could not complete this request.',
guidance:
'Try the action again. If it keeps failing, check for updates in Extensions or try another source.',
details,
};
}
if (/^mpv could not play this stream|^Playback did not start\./.test(message)) {
return {
title: 'Could not start playback',
explanation: 'mpv could not start the selected stream.',
guidance:
'Try playing the episode again to request a fresh stream, or choose another source.',
details,
};
}
return { title, explanation: message, guidance: '', details: '' };
}