cron/
error.rs

1use std::{error, fmt};
2
3/// A cron error
4#[derive(Debug)]
5pub struct Error {
6    kind: ErrorKind,
7}
8
9/// The kind of cron error that occurred
10#[derive(Debug)]
11pub enum ErrorKind {
12    /// Failed to parse an expression
13    Expression(String),
14}
15
16impl fmt::Display for Error {
17    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18        match self.kind {
19            ErrorKind::Expression(ref expr) => write!(f, "Invalid expression: {}", expr),
20        }
21    }
22}
23
24impl error::Error for Error {}
25
26impl From<ErrorKind> for Error {
27    fn from(kind: ErrorKind) -> Error {
28        Error { kind }
29    }
30}