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