oximedia_subtitle/
error.rs1use thiserror::Error;
4
5pub type SubtitleResult<T> = Result<T, SubtitleError>;
7
8#[derive(Debug, Error)]
10pub enum SubtitleError {
11 #[error("Parse error: {0}")]
13 ParseError(String),
14
15 #[error("Invalid subtitle format: {0}")]
17 InvalidFormat(String),
18
19 #[error("Invalid timestamp: {0}")]
21 InvalidTimestamp(String),
22
23 #[error("Font loading error: {0}")]
25 FontError(String),
26
27 #[error("Text rendering error: {0}")]
29 RenderError(String),
30
31 #[error("Invalid color: {0}")]
33 InvalidColor(String),
34
35 #[error("Invalid style: {0}")]
37 InvalidStyle(String),
38
39 #[error("Unsupported feature: {0}")]
41 UnsupportedFeature(String),
42
43 #[error("I/O error: {0}")]
45 IoError(String),
46
47 #[error("Invalid frame format: {0}")]
49 InvalidFrameFormat(String),
50
51 #[error("Internal error: {0}")]
53 Internal(String),
54}
55
56impl From<std::io::Error> for SubtitleError {
57 fn from(err: std::io::Error) -> Self {
58 Self::IoError(err.to_string())
59 }
60}
61
62impl From<std::string::FromUtf8Error> for SubtitleError {
63 fn from(err: std::string::FromUtf8Error) -> Self {
64 Self::ParseError(format!("UTF-8 decode error: {err}"))
65 }
66}