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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
//! Result and error types for NEXRAD data operations.
use thiserror::Error as ThisError;
/// A specialized Result type for NEXRAD data operations.
pub type Result<T> = std::result::Result<T, Error>;
/// Errors that can occur during NEXRAD data operations.
#[derive(ThisError, Debug)]
pub enum Error {
/// An I/O error occurred while reading or writing data.
#[error("data file IO error")]
Io(#[from] std::io::Error),
/// Attempted to decompress data that is not compressed.
#[error("error decompressing uncompressed data")]
UncompressedData,
/// An AWS-related error occurred (requires `aws` feature).
#[cfg(feature = "aws")]
#[error(transparent)]
AWS(#[from] aws::AWSError),
/// An error occurred during message decoding.
#[error("error decoding NEXRAD data")]
Decode(#[from] nexrad_decode::result::Error),
/// An error occurred in the common model layer (requires `nexrad-model` feature).
#[cfg(feature = "nexrad-model")]
#[error("error in common model")]
Model(#[from] nexrad_model::result::Error),
/// Cannot decode compressed record data without decompression.
#[error("compressed data cannot be decoded")]
CompressedData,
/// Cannot access records or scan from a gzip-compressed volume file.
/// Call `decompress()` first.
#[error("gzip-compressed volume file must be decompressed before accessing records")]
CompressedFile,
/// Volume file is missing the required VCP (message type 5).
#[error("volume missing coverage pattern (message type 5)")]
MissingCoveragePattern,
/// BZIP2 decompression of an LDM record failed.
#[error("ldm record decompression error")]
Decompression(#[from] bzip2::Error),
/// LDM record was truncated and contains fewer bytes than expected.
#[error("truncated record: expected {expected} bytes, got {actual}")]
TruncatedRecord {
/// Expected number of bytes.
expected: usize,
/// Actual number of bytes present.
actual: usize,
},
/// LDM record size is invalid at the given file offset.
#[error("invalid record size {size} at offset {offset}")]
InvalidRecordSize {
/// The invalid size value.
size: usize,
/// File offset where the invalid size was found.
offset: usize,
},
}
/// AWS-related error types (requires `aws` feature).
#[cfg(feature = "aws")]
pub mod aws {
use thiserror::Error as ThisError;
/// Errors that can occur during AWS S3 operations.
#[derive(ThisError, Debug)]
pub enum AWSError {
/// S3 list objects response was unexpectedly truncated.
#[error("unexpected truncated S3 list objects response")]
TruncatedListObjectsResponse,
/// Failed to parse date/time from filename or metadata.
#[error("error decoding date/time")]
DateTime(String),
/// The radar site identifier is not recognized.
#[error("invalid radar site identifier")]
InvalidSiteIdentifier(String),
/// Real-time chunk data is in an unrecognized format.
#[error("chunk data in unrecognized format")]
UnrecognizedChunkFormat,
/// Could not parse date/time from chunk filename.
#[error("unrecognized chunk date time")]
UnrecognizedChunkDateTime(String),
/// Could not parse sequence number from chunk filename.
#[error("unrecognized chunk sequence")]
UnrecognizedChunkSequence(String),
/// Chunk type character is not recognized.
#[error("unrecognized chunk type")]
UnrecognizedChunkType(Option<char>),
/// S3 list objects request failed.
#[error("error listing AWS S3 objects")]
S3ListObjects(reqwest::Error),
/// S3 get object request failed to send.
#[error("error requesting AWS S3 object")]
S3GetObjectRequest(reqwest::Error),
/// S3 get object returned an error response.
#[error("error getting AWS S3 object")]
S3GetObject(Option<String>),
/// Requested S3 object was not found (404).
#[error("AWS S3 object not found")]
S3ObjectNotFound,
/// Error while streaming/downloading S3 object content.
#[error("error streaming/downloading AWS S3 object")]
S3Streaming(reqwest::Error),
/// Could not find the latest volume for the requested site/date.
#[error("failed to locate latest volume")]
LatestVolumeNotFound,
/// An expected chunk was not found during real-time polling.
#[error("a chunk was not found as expected")]
ExpectedChunkNotFound,
/// Error in async channel communication during polling.
#[error("error sending chunk to receiver")]
PollingAsync,
/// Could not determine the next chunk to poll.
#[error("failed to determine next chunk")]
FailedToDetermineNextChunk,
/// Failed to decode XML response from S3 list objects.
#[error("error decoding S3 list objects response")]
S3ListObjectsDecoding,
}
}