chrono_systemd_time/
error.rs

1/// Describes an error during the parsing of a timestamp.
2#[derive(Debug)]
3pub enum Error {
4    /// The timestamp is incorrectly formatted.
5    Format(String),
6    /// The timestamp contains a component that cannot be parsed into a number, or the number overflowed.
7    Number(String),
8    /// The timestamp contains a component that cannot be parsed into a time unit.
9    TimeUnit(String),
10    /// The timestamp is invalid in the given timezone.
11    Never,
12}
13
14impl std::error::Error for Error {}
15
16impl std::fmt::Display for Error {
17    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
18        match self {
19            Error::Format(emsg) => write!(f, "invalid timestamp format: {emsg}"),
20            Error::Number(emsg) => write!(f, "invalid timestamp number: {emsg}"),
21            Error::TimeUnit(unit) => write!(f, "invalid time unit: {unit}"),
22            Error::Never => write!(f, "invalid timestamp in the given timezone"),
23        }
24    }
25}