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