use alloc::string::String;
use core::fmt;
#[derive(Debug)]
pub enum EopParseError {
InvalidLine { line: usize, reason: &'static str },
InvalidNumber {
line: usize,
column: &'static str,
value: String,
},
Empty,
NonMonotonicMjd {
line: usize,
previous: f64,
current: f64,
},
}
impl fmt::Display for EopParseError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::InvalidLine { line, reason } => {
write!(f, "line {line}: {reason}")
}
Self::InvalidNumber {
line,
column,
value,
} => write!(f, "line {line}: invalid number in '{column}': \"{value}\""),
Self::Empty => write!(f, "no valid EOP entries found"),
Self::NonMonotonicMjd {
line,
previous,
current,
} => write!(f, "line {line}: non-monotonic MJD: {previous} -> {current}"),
}
}
}
impl core::error::Error for EopParseError {}
#[derive(Debug)]
pub enum EopLookupError {
Empty,
OutOfRange { mjd: f64, start: f64, end: f64 },
}
impl fmt::Display for EopLookupError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Empty => write!(f, "EOP table is empty"),
Self::OutOfRange { mjd, start, end } => {
write!(f, "MJD {mjd} outside EOP range [{start}, {end}]")
}
}
}
}
impl core::error::Error for EopLookupError {}