nexrad_data/
result.rs

1//!
2//! Contains the Result and Error types for NEXRAD operations.
3//!
4
5use thiserror::Error as ThisError;
6
7pub type Result<T> = std::result::Result<T, Error>;
8
9#[derive(ThisError, Debug)]
10pub enum Error {
11    #[error("data file IO error")]
12    FileError(#[from] std::io::Error),
13    #[error("file deserialization error")]
14    #[cfg(feature = "bincode")]
15    DeserializationError(#[from] bincode::Error),
16    #[cfg(feature = "bzip2")]
17    #[error("error decompressing uncompressed data")]
18    UncompressedDataError,
19    #[cfg(feature = "aws")]
20    #[error(transparent)]
21    AWS(#[from] aws::AWSError),
22    #[cfg(feature = "decode")]
23    #[error("error decoding NEXRAD data")]
24    Decode(#[from] nexrad_decode::result::Error),
25    #[cfg(feature = "nexrad-model")]
26    #[error("error in common model")]
27    Model(#[from] nexrad_model::result::Error),
28    #[cfg(feature = "decode")]
29    #[error("compressed data cannot be decoded")]
30    CompressedDataError,
31    #[cfg(feature = "decode")]
32    #[error("volume missing coverage pattern number")]
33    MissingCoveragePattern,
34    #[cfg(feature = "bzip2")]
35    #[error("ldm record decompression error")]
36    DecompressionError(#[from] bzip2::Error),
37}
38
39#[cfg(feature = "aws")]
40pub mod aws {
41    use thiserror::Error as ThisError;
42
43    #[derive(ThisError, Debug)]
44    pub enum AWSError {
45        #[error("unexpected truncated S3 list objects response")]
46        TruncatedListObjectsResponse,
47        #[error("error decoding date/time")]
48        DateTimeError(String),
49        #[error("invalid radar site identifier")]
50        InvalidSiteIdentifier(String),
51        #[error("chunk data in unrecognized format")]
52        UnrecognizedChunkFormat,
53        #[error("error listing AWS S3 objects")]
54        S3ListObjectsError(reqwest::Error),
55        #[error("error requesting AWS S3 object")]
56        S3GetObjectRequestError(reqwest::Error),
57        #[error("error getting AWS S3 object")]
58        S3GetObjectError(Option<String>),
59        #[error("AWS S3 object not found")]
60        S3ObjectNotFoundError,
61        #[error("error streaming/downloading AWS S3 object")]
62        S3StreamingError(reqwest::Error),
63        #[error("failed to locate latest volume")]
64        LatestVolumeNotFound,
65        #[error("a chunk was not found as expected")]
66        ExpectedChunkNotFound,
67        #[error("error sending chunk to receiver")]
68        PollingAsyncError,
69        #[error("failed to determine next chunk")]
70        FailedToDetermineNextChunk,
71        #[error("error decoding S3 list objects response")]
72        S3ListObjectsDecodingError,
73    }
74}