aprs/
error.rs

1//! APRS protocol error type.
2
3use thiserror::Error;
4
5/// Errors produced by APRS parsing, building, and stateful algorithms.
6#[derive(Debug, Clone, PartialEq, Eq, Error)]
7pub enum AprsError {
8    /// The info field is too short or has an unrecognized data type.
9    #[error("invalid APRS format")]
10    InvalidFormat,
11    /// The position coordinates could not be parsed.
12    #[error("invalid APRS coordinates")]
13    InvalidCoordinates,
14    /// Mic-E data requires the AX.25 destination address for decoding.
15    #[error("Mic-E data requires destination address \u{2014} use parse_aprs_data_full()")]
16    MicERequiresDestination,
17    /// A digipeater path string could not be parsed.
18    #[error("invalid digipeater path: {0}")]
19    InvalidPath(String),
20    /// The message text is too long (APRS 1.0.1 ยง14: max 67 characters).
21    #[error("APRS message text exceeds 67 characters ({0} bytes)")]
22    MessageTooLong(usize),
23
24    // --- Validation variants for wire newtypes (Task 3) ---
25    /// Latitude is not finite or outside `-90.0..=90.0`.
26    #[error("invalid latitude: {0}")]
27    InvalidLatitude(&'static str),
28
29    /// Longitude is not finite or outside `-180.0..=180.0`.
30    #[error("invalid longitude: {0}")]
31    InvalidLongitude(&'static str),
32
33    /// Speed value is out of range.
34    #[error("invalid speed: {0}")]
35    InvalidSpeed(&'static str),
36
37    /// Course is outside `0..=360` degrees.
38    #[error("invalid course: {0}")]
39    InvalidCourse(&'static str),
40
41    /// Message ID is empty, too long, or contains non-alphanumeric bytes.
42    #[error("invalid message ID: {0}")]
43    InvalidMessageId(&'static str),
44
45    /// Temperature (Fahrenheit) is outside `-99..=999`.
46    #[error("invalid temperature: {0}")]
47    InvalidTemperature(&'static str),
48
49    /// Symbol table code is not `/`, `\`, `0-9`, or `A-Z`.
50    #[error("invalid symbol table: {0}")]
51    InvalidSymbolTable(&'static str),
52
53    /// APRS symbol code is outside the printable ASCII range.
54    #[error("invalid APRS symbol: {0}")]
55    InvalidSymbol(&'static str),
56
57    /// Tocall string does not satisfy callsign format rules.
58    #[error("invalid tocall: {0}")]
59    InvalidTocall(&'static str),
60
61    /// Digipeater alias failed validation (empty, non-ASCII).
62    #[error("invalid digipeater alias: {0}")]
63    InvalidDigipeaterAlias(&'static str),
64}