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("ASS parse error: {message}")]
41 AssParse { message: String },
42
43 #[error("translation response is invalid: {message}")]
45 InvalidTranslation { message: String },
46
47 #[error("{provider} error: {message}")]
49 Translation {
50 provider: &'static str,
51 message: String,
52 },
53}
54
55pub type Result<T> = std::result::Result<T, SubtitleToolkitError>;