use indexkv::StreamError;
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("year missing")]
YearMissing,
#[error("season missing")]
SeasonMissing,
#[error("episode missing")]
EpisodeMissing,
#[error("wrong media type {0} for {1}")]
WrongMediaType(&'static str, &'static str),
#[error("HTTP error: {0}")]
HTTP(#[from] reqwest::Error),
#[error("CSV error: {0}")]
CSV(#[from] csv_async::Error),
#[error("I/O error: {0}")]
IO(#[from] std::io::Error),
#[error("failed to do math on system times: {0}")]
SystemTime(#[from] std::time::SystemTimeError),
#[error("title ID {0} not found")]
NotFound(u32),
#[error("cache failure: {0}")]
Cache(#[from] indexkv::Error<u32>),
#[error("invalid genre {0}")]
InvalidGenre(String)
}
impl From<StreamError<Error, u32>> for Error {
fn from(other: StreamError<Error, u32>) -> Self {
match other {
StreamError::Internal(e) => Self::from(e),
StreamError::Caller(e) => e
}
}
}