use std::fmt;
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum ParseDurationError {
Empty,
ExpectedNumber {
index: usize,
},
MissingUnit {
index: usize,
},
UnknownUnit {
index: usize,
},
Overflow,
}
impl fmt::Display for ParseDurationError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Empty => write!(f, "empty duration"),
Self::ExpectedNumber { index } => write!(f, "expected a number at byte {index}"),
Self::MissingUnit { index } => write!(f, "expected a unit at byte {index}"),
Self::UnknownUnit { index } => write!(f, "unknown unit at byte {index}"),
Self::Overflow => write!(f, "duration is too large"),
}
}
}
impl std::error::Error for ParseDurationError {}
#[cfg(test)]
#[path = "error.test.rs"]
mod tests;