22 lines
484 B
Rust
22 lines
484 B
Rust
use std::error::Error;
|
|||
|
|
use std::fmt::{Debug, Display, Formatter};
|
||
|
|
|
||
|
|
#[derive(Debug, Eq, PartialEq)]
|
||
|
|
pub enum AppError {
|
||
|
|
HourParseError
|
||
|
|
}
|
||
|
|
|
||
|
|
impl AppError {
|
||
|
|
fn as_string(&self) -> String {
|
||
|
|
//match self { AppError::HourParseError => {"Hour parse error"} }
|
||
|
|
"Hours parse error".to_string()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
impl Display for AppError {
|
||
|
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||
|
|
write!(f, "{}", self.as_string())
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
impl Error for AppError {}
|