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 GLONASS G1/G2 frequency lookup did not receive an FDMA channel.
20 MissingGlonassChannel,
21 /// A requested terrain tile is not present in the terrain store.
22 MissingTerrainTile {
23 /// Integer latitude tile id.
24 lat_index: i32,
25 /// Integer longitude tile id.
26 lon_index: i32,
27 },
28 /// An IONEX slant-delay query lies outside the product coverage.
29 IonexOutOfCoverage(crate::ionex::IonexCoverageError),
30 /// A requested epoch lies outside the sampled / valid span.
31 EpochOutOfRange,
32 /// An operation received inputs it cannot combine (e.g. an empty set of
33 /// products to merge, or products on mismatched time scales, epoch grids, or
34 /// coordinate-system labels).
35 InvalidInput(String),
36}
37
38impl fmt::Display for Error {
39 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
40 match self {
41 Error::Parse(msg) => write!(f, "parse error: {msg}"),
42 Error::UnknownSatellite(id) => write!(f, "unknown satellite: {id}"),
43 Error::MissingGlonassChannel => write!(f, "missing GLONASS FDMA channel"),
44 Error::MissingTerrainTile {
45 lat_index,
46 lon_index,
47 } => write!(f, "missing terrain tile ({lat_index},{lon_index})"),
48 Error::IonexOutOfCoverage(error) => write!(f, "IONEX out of coverage: {error}"),
49 Error::EpochOutOfRange => write!(f, "epoch out of range"),
50 Error::InvalidInput(msg) => write!(f, "invalid input: {msg}"),
51 }
52 }
53}
54
55impl std::error::Error for Error {}