use thiserror::Error;
pub type SubtitleResult<T> = Result<T, SubtitleError>;
#[derive(Debug, Error)]
pub enum SubtitleError {
#[error("Parse error: {0}")]
ParseError(String),
#[error("Invalid subtitle format: {0}")]
InvalidFormat(String),
#[error("Invalid timestamp: {0}")]
InvalidTimestamp(String),
#[error("Font loading error: {0}")]
FontError(String),
#[error("Text rendering error: {0}")]
RenderError(String),
#[error("Invalid color: {0}")]
InvalidColor(String),
#[error("Invalid style: {0}")]
InvalidStyle(String),
#[error("Unsupported feature: {0}")]
UnsupportedFeature(String),
#[error("I/O error: {0}")]
IoError(String),
#[error("Invalid frame format: {0}")]
InvalidFrameFormat(String),
#[error("Internal error: {0}")]
Internal(String),
}
impl From<std::io::Error> for SubtitleError {
fn from(err: std::io::Error) -> Self {
Self::IoError(err.to_string())
}
}
impl From<std::string::FromUtf8Error> for SubtitleError {
fn from(err: std::string::FromUtf8Error) -> Self {
Self::ParseError(format!("UTF-8 decode error: {err}"))
}
}