target_match/error.rs
1//! Error type for `target-match`.
2//!
3//! Every fallible entry point returns [`Result`]. The only construction this
4//! crate itself validates is optics/field geometry — coordinate parsing and
5//! domain checks happen in [`skymath`] when the consumer builds an
6//! [`skymath::Equatorial`], and surface as [`skymath::Error`]. Matching and
7//! precession are infallible once inputs are valid values.
8
9use thiserror::Error;
10
11/// Everything that can go wrong constructing `target-match` values.
12#[derive(Debug, Clone, PartialEq, Error)]
13#[non_exhaustive]
14pub enum Error {
15 /// Optics or field inputs were non-positive, non-finite, or insufficient to
16 /// derive a field of view.
17 #[error("invalid optics: {0}")]
18 InvalidOptics(String),
19}
20
21/// Convenience alias for `Result<T, `[`Error`](enum@Error)`>`.
22pub type Result<T> = core::result::Result<T, Error>;
23
24#[cfg(test)]
25mod tests {
26 use super::*;
27
28 #[test]
29 fn display_messages() {
30 assert_eq!(
31 Error::InvalidOptics("focal <= 0".into()).to_string(),
32 "invalid optics: focal <= 0"
33 );
34 }
35}