1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//!
//! Contains the Result and Error types for NEXRAD operations.
//!

use thiserror::Error as ThisError;

pub type Result<T> = std::result::Result<T, Error>;

#[derive(ThisError, Debug)]
pub enum Error {
    #[error("data file IO error")]
    FileError(#[from] std::io::Error),
    #[error("file deserialization error")]
    #[cfg(feature = "bincode")]
    DeserializationError(#[from] bincode::Error),
    #[cfg(feature = "bzip2")]
    #[error("error decompressing uncompressed data")]
    UncompressedDataError,
    #[cfg(feature = "aws")]
    #[error(transparent)]
    AWS(#[from] aws::AWSError),
    #[cfg(feature = "decode")]
    #[error("error decoding NEXRAD data")]
    Decode(#[from] nexrad_decode::result::Error),
    #[cfg(feature = "nexrad-model")]
    #[error("error in common model")]
    Model(#[from] nexrad_model::result::Error),
    #[cfg(feature = "decode")]
    #[error("compressed data cannot be decoded")]
    CompressedDataError,
    #[cfg(feature = "decode")]
    #[error("volume missing coverage pattern number")]
    MissingCoveragePattern,
    #[cfg(feature = "bzip2")]
    #[error("ldm record decompression error")]
    DecompressionError(#[from] bzip2::Error),
}

#[cfg(feature = "aws")]
pub mod aws {
    use thiserror::Error as ThisError;

    #[derive(ThisError, Debug)]
    pub enum AWSError {
        #[error("unexpected truncated S3 list objects response")]
        TruncatedListObjectsResponse,
        #[error("error decoding date/time")]
        DateTimeError(String),
        #[error("invalid radar site identifier")]
        InvalidSiteIdentifier(String),
        #[error("chunk data in unrecognized format")]
        UnrecognizedChunkFormat,
        #[error("error listing AWS S3 objects")]
        S3ListObjectsError(reqwest::Error),
        #[error("error requesting AWS S3 object")]
        S3GetObjectRequestError(reqwest::Error),
        #[error("error getting AWS S3 object")]
        S3GetObjectError(Option<String>),
        #[error("AWS S3 object not found")]
        S3ObjectNotFoundError,
        #[error("error streaming/downloading AWS S3 object")]
        S3StreamingError(reqwest::Error),
        #[error("failed to locate latest volume")]
        LatestVolumeNotFound,
        #[error("a chunk was not found as expected")]
        ExpectedChunkNotFound,
        #[error("error sending chunk to receiver")]
        PollingAsyncError,
        #[error("failed to determine next chunk")]
        FailedToDetermineNextChunk,
        #[error("error decoding S3 list objects response")]
        S3ListObjectsDecodingError,
    }
}