sidereon_core/error.rs
1//! Crate error type.
2//!
3//! The variants cover broad parsing, lookup, interpolation, and invalid-input
4//! failures across the crate.
5
6use core::fmt;
7
8/// Result alias for fallible `sidereon-core` operations.
9pub type Result<T> = core::result::Result<T, Error>;
10
11/// Errors produced by the `sidereon-core` crate.
12#[derive(Debug, Clone, PartialEq, Eq)]
13#[non_exhaustive]
14pub enum Error {
15 /// A product (SP3/RINEX/IONEX) could not be parsed.
16 Parse(String),
17 /// A requested satellite is not present in the product.
18 UnknownSatellite(crate::GnssSatelliteId),
19 /// A requested epoch lies outside the sampled / valid span.
20 EpochOutOfRange,
21 /// An operation received inputs it cannot combine (e.g. an empty set of
22 /// products to merge, or products on mismatched time scales, epoch grids, or
23 /// coordinate-system labels).
24 InvalidInput(String),
25}
26
27impl fmt::Display for Error {
28 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
29 match self {
30 Error::Parse(msg) => write!(f, "parse error: {msg}"),
31 Error::UnknownSatellite(id) => write!(f, "unknown satellite: {id}"),
32 Error::EpochOutOfRange => write!(f, "epoch out of range"),
33 Error::InvalidInput(msg) => write!(f, "invalid input: {msg}"),
34 }
35 }
36}
37
38impl std::error::Error for Error {}