Skip to main content

sdr_acars/
error.rs

1//! Error type for the `sdr-acars` crate.
2//!
3//! Per project library-crate rules: all fallible paths return
4//! `Result<_, AcarsError>` — no `unwrap()`, no `panic!()`, no
5//! stringly-typed errors.
6
7use thiserror::Error;
8
9/// All ways `sdr-acars` can fail.
10#[derive(Debug, Error)]
11pub enum AcarsError {
12    /// `ChannelBank::new` got an invalid configuration: empty
13    /// channel list, source rate / center freq combination that
14    /// can't fit all channels, or per-channel rate mismatch.
15    #[error("invalid channel configuration: {0}")]
16    InvalidChannelConfig(String),
17
18    /// Decimation factor isn't an integer for the requested
19    /// source rate / IF rate combo. Source rate must be an
20    /// integer multiple of `12_500` Hz.
21    #[error(
22        "source rate {source_rate_hz} Hz is not an integer multiple of IF rate {if_rate_hz} Hz"
23    )]
24    NonIntegerDecimation {
25        source_rate_hz: f64,
26        if_rate_hz: f64,
27    },
28
29    /// CLI / file I/O — failed to read input file.
30    #[error("I/O error reading {path}: {source}")]
31    Io {
32        path: std::path::PathBuf,
33        #[source]
34        source: std::io::Error,
35    },
36
37    /// CLI — input file format isn't recognized (WAV header
38    /// missing, IQ file size not a multiple of 4 bytes for
39    /// interleaved i16 I/Q, etc.).
40    #[error("invalid input format: {0}")]
41    InvalidInput(String),
42}