use std::fmt;
use std::num::ParseIntError;
#[derive(Debug)]
pub enum CrontabError {
ErrCronFormat(String),
ErrParseInt(ParseIntError),
FieldOutsideRange {
description: String,
},
}
impl From<ParseIntError> for CrontabError {
fn from(err: ParseIntError) -> CrontabError {
CrontabError::ErrParseInt(err)
}
}
impl fmt::Display for CrontabError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
&CrontabError::ErrCronFormat(ref x) => write!(f, "<ErrCronFormat> {:?}", x),
&CrontabError::ErrParseInt(ref e) => write!(f, "<ErrParseInt> {:?}", e),
&CrontabError::FieldOutsideRange{ ref description } => {
write!(f, "<FieldOutsideRange> {:?}", description)
},
}
}
}