1use thiserror::Error;
6
7#[derive(Debug, Error)]
9pub enum ScheduleError {
10 #[error("Invalid schedule: {0}")]
11 Invalid(String),
12
13 #[error("Not implemented: {0}")]
14 NotImplemented(String),
15
16 #[error("Parsing error: {0}")]
17 Parse(String),
18
19 #[error("Persistence error: {0}")]
20 Persistence(String),
21}
22
23impl ScheduleError {
24 pub fn is_invalid(&self) -> bool {
26 matches!(self, ScheduleError::Invalid(_))
27 }
28
29 pub fn is_not_implemented(&self) -> bool {
31 matches!(self, ScheduleError::NotImplemented(_))
32 }
33
34 pub fn is_parse(&self) -> bool {
36 matches!(self, ScheduleError::Parse(_))
37 }
38
39 pub fn is_persistence(&self) -> bool {
41 matches!(self, ScheduleError::Persistence(_))
42 }
43
44 pub fn is_retryable(&self) -> bool {
49 matches!(self, ScheduleError::Persistence(_))
50 }
51
52 pub fn category(&self) -> &'static str {
54 match self {
55 ScheduleError::Invalid(_) => "invalid",
56 ScheduleError::NotImplemented(_) => "not_implemented",
57 ScheduleError::Parse(_) => "parse",
58 ScheduleError::Persistence(_) => "persistence",
59 }
60 }
61}