countrs/
errors.rs

1use std::fmt::{Display, Formatter, Result};
2
3#[derive(Debug)]
4pub struct InvalidDirection;
5
6impl std::error::Error for InvalidDirection {}
7
8impl Display for InvalidDirection {
9    fn fmt(&self, f: &mut Formatter<'_>) -> Result {
10        write!(f, "{:?}", self)
11    }
12}
13
14#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)]
15pub struct TimeParserError;
16
17impl std::error::Error for TimeParserError {}
18
19impl Display for TimeParserError {
20    fn fmt(&self, f: &mut Formatter<'_>) -> Result {
21        write!(f, "{}", "Tried to parse invalid time string")
22    }
23}
24
25#[derive(Debug)]
26pub struct TimeOverflow;
27
28impl std::error::Error for TimeOverflow {}
29
30impl Display for TimeOverflow {
31    fn fmt(&self, f: &mut Formatter<'_>) -> Result {
32        write!(f, "{}", "Time could not be added due to an overflow")
33    }
34}