use crate::state::State;
use crate::timeline::TimelineError;
use std::error::Error as StdError;
use std::fmt;
pub enum Error<S: State> {
Timeline(TimelineError<S::Error>),
}
impl<S: State> From<TimelineError<S::Error>> for Error<S>
where
S::Error: fmt::Debug,
{
fn from(source: TimelineError<S::Error>) -> Error<S> {
Error::Timeline(source)
}
}
impl<S: State> fmt::Debug for Error<S>
where
S::Error: fmt::Debug,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::Timeline(e) => write!(f, "Error::Timeline( {:?} )", e),
}
}
}
impl<S: State> fmt::Display for Error<S>
where
S::Error: fmt::Display + fmt::Debug,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::Timeline(e) => write!(f, "[Timeline error]: {}", e),
}
}
}
impl<S: State> StdError for Error<S>
where
S: fmt::Debug,
S::Error: fmt::Display + fmt::Debug,
{
}