tonhowtf/omniget · error
subtitle_load error surfaced to user via err() (localized…
Error message
subtitle_load error surfaced to user via err() (localized toast)
What it means
SubtitleWorkshop's loadFile failed while invoking the Rust command subtitle_load for the selected subtitle path, and the raw error string is routed through err() to be shown as a localized toast. The workshop keeps previous cues; only the new file load failed.
Solutions
- Read the toast/err text: 'ai_not_configured' style raw codes are mapped, otherwise backend error strings are shown — identify file-not-found vs parse error.
- Verify the path exists and is readable before invoking.
- Try re-encoding the subtitle file to UTF-8.
- Check the backend subtitle_load implementation for format limitations (e.g. only SRT supported).
Example fix
// before
} catch (e) { err(e); }
// after
} catch (e) {
if (typeof e !== "string") err("invalid_subtitle_format");
else err(e);
} Defensive patterns
Strategy: validation
Validate before calling
const exists = await invoke<boolean>("path_exists", { path: sel }).catch(() => false);
if (!exists) { showToast("error", $t("downloads.sw.file_missing")); return; } Type guard
function isSubtitlePath(v: unknown): v is string {
return typeof v === "string" && /\.(srt|ass|vtt)$/i.test(v);
} Try / catch
try {
cues = await invoke<Cue[]>("subtitle_load", { path: sel });
} catch (e) {
err(e); // maps raw backend codes to localized toast messages
} finally {
busy = false;
} Prevention
- Verify the file still exists right before invoking (paths can go stale).
- Restrict the file picker to supported subtitle extensions.
- Convert non-UTF8 subtitles to UTF-8 before loading.
- Keep err()'s raw-code mapping table in sync with backend error codes.
When it happens
Trigger: invoke('subtitle_load',{path:sel}) rejecting — file doesn't exist, unreadable, or the parser rejects the subtitle format/encoding (invalid SRT/ASS content).
Common situations: User picks a file that was moved/deleted after listing; non-UTF8 encodings; malformed subtitle files; path with characters the backend mishandles.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- $t('common.error') | mapped: ai_not_configured ->…
- waveform_peaks/detect_shot_changes error surfaced to user…
- subtitle_translate error surfaced to user via err()…
- subtitle_grammar_fix error surfaced to user via err()…
- escolha a pasta de destino para organizar
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/35de34dc72bfc09c.
Report an issue: GitHub.
Appendix: source
Thrown at src/components/downloads/SubtitleWorkshop.svelte:72
(parseInt(m[1]) * 3600 + parseInt(m[2]) * 60 + parseInt(m[3])) * 1000 +
parseInt(m[4].padEnd(3, "0"))
);
}
async function loadFile() {
const sel = await openDialog({
multiple: false,
filters: [{ name: "Subtitles", extensions: ["srt", "vtt", "ass"] }],
});
if (!sel || typeof sel !== "string") return;
busy = true;
try {
cues = await invoke<Cue[]>("subtitle_load", { path: sel });
loadedPath = sel;
peaks = [];
shots = [];
} catch (e) {
err(e);
} finally {
busy = false;
}
}
async function loadMedia() {
const sel = await openDialog({ multiple: false });
if (!sel || typeof sel !== "string") return;
busy = true;
try {
peaks = await invoke<number[]>("waveform_peaks", { input: sel, buckets: 600 });
shots = await invoke<number[]>("detect_shot_changes", { input: sel, threshold: 0.4 });
} catch (e) {
err(e);
} finally {
busy = false;
}
}View on GitHub (pinned to 8600b91f42)