use thiserror::Error;
#[derive(Debug, Error)]
pub enum ScheduleError {
#[error("Invalid schedule: {0}")]
Invalid(String),
#[error("Not implemented: {0}")]
NotImplemented(String),
#[error("Parsing error: {0}")]
Parse(String),
#[error("Persistence error: {0}")]
Persistence(String),
}
impl ScheduleError {
pub fn is_invalid(&self) -> bool {
matches!(self, ScheduleError::Invalid(_))
}
pub fn is_not_implemented(&self) -> bool {
matches!(self, ScheduleError::NotImplemented(_))
}
pub fn is_parse(&self) -> bool {
matches!(self, ScheduleError::Parse(_))
}
pub fn is_persistence(&self) -> bool {
matches!(self, ScheduleError::Persistence(_))
}
pub fn is_retryable(&self) -> bool {
matches!(self, ScheduleError::Persistence(_))
}
pub fn category(&self) -> &'static str {
match self {
ScheduleError::Invalid(_) => "invalid",
ScheduleError::NotImplemented(_) => "not_implemented",
ScheduleError::Parse(_) => "parse",
ScheduleError::Persistence(_) => "persistence",
}
}
}