psyche_subtitle_toolkit/
error.rs1use std::io;
2use std::path::PathBuf;
3
4#[derive(Debug, thiserror::Error)]
6pub enum SubtitleToolkitError {
7 #[error("I/O error: {0}")]
9 Io(#[from] io::Error),
10
11 #[error("HTTP error: {0}")]
13 Http(#[from] reqwest::Error),
14
15 #[error("JSON error: {0}")]
17 Json(#[from] serde_json::Error),
18
19 #[error("required tool `{tool}` was not found in PATH")]
21 MissingTool { tool: &'static str },
22
23 #[error("command `{program}` failed with status {status}: {stderr}")]
25 CommandFailed {
26 program: &'static str,
27 status: String,
28 stderr: String,
29 },
30
31 #[error("no MKV files found at {path}")]
33 NoMkvFiles { path: PathBuf },
34
35 #[error("no ASS subtitle track found in {path}")]
37 NoAssTrack { path: PathBuf },
38
39 #[error("no supported subtitle track found in {path}")]
41 NoSubtitleTrack { path: PathBuf },
42
43 #[error("ASS parse error: {message}")]
45 AssParse { message: String },
46
47 #[error("SRT parse error: {message}")]
49 SrtParse { message: String },
50
51 #[error("WebVTT parse error: {message}")]
53 VttParse { message: String },
54
55 #[error("translation response is invalid: {message}")]
57 InvalidTranslation { message: String },
58
59 #[error("{provider} error: {message}")]
61 Translation {
62 provider: &'static str,
63 message: String,
64 },
65}
66
67pub type Result<T> = std::result::Result<T, SubtitleToolkitError>;