atfits_rs/error.rs
1//! Error type shared by the low-level cfitsio helpers.
2//!
3//! Consuming crates wrap this in their own error enum with
4//! `#[error(...)] Atfits(#[from] atfits_rs::AtfitsError)` (or map individual
5//! variants), so a `?` on any helper here flows into their `Result`.
6use thiserror::Error;
7
8/// Errors raised by the shared cfitsio helpers.
9#[derive(Debug, Error)]
10pub enum AtfitsError {
11 /// Underlying cfitsio error.
12 #[error("FITS I/O error: {0}")]
13 Fits(#[from] fitsio::errors::Error),
14
15 /// Filesystem I/O error.
16 #[error("I/O error: {0}")]
17 Io(#[from] std::io::Error),
18
19 /// A required header keyword was absent.
20 #[error("missing header keyword: {0}")]
21 MissingKeyword(String),
22
23 /// A requested target (e.g. FREQ/TIME) axis was not found in the WCS.
24 #[error("target axis missing: {0}")]
25 TargetAxisMissing(String),
26
27 /// A FITS image had an unexpected dimensionality.
28 #[error("unsupported NAXIS={0}")]
29 UnsupportedNaxis(i64),
30
31 /// Catch-all for invariant violations.
32 #[error("{0}")]
33 Other(String),
34}
35
36/// Convenience result alias for the shared helpers.
37pub type Result<T> = std::result::Result<T, AtfitsError>;