1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, Error>;
4
5#[derive(Debug, Error)]
6pub enum Error {
7 #[error("I/O error reading {1}: {0}")]
8 Io(#[source] std::io::Error, String),
9
10 #[error("no GRIB messages found in file")]
11 NoMessages,
12
13 #[error("message index {0} not found")]
14 MessageNotFound(usize),
15
16 #[error("unsupported GRIB edition: {0}")]
17 UnsupportedEdition(u8),
18
19 #[error("invalid GRIB message: {0}")]
20 InvalidMessage(String),
21
22 #[error("invalid section {section}: {reason}")]
23 InvalidSection { section: u8, reason: String },
24
25 #[error("invalid section order: {0}")]
26 InvalidSectionOrder(String),
27
28 #[error("unsupported grid definition template: {0}")]
29 UnsupportedGridTemplate(u16),
30
31 #[error("unsupported data representation template: {0}")]
32 UnsupportedDataTemplate(u16),
33
34 #[error("unsupported complex packing group splitting method: {0}")]
35 UnsupportedGroupSplittingMethod(u8),
36
37 #[error("unsupported complex packing missing value management: {0}")]
38 UnsupportedMissingValueManagement(u8),
39
40 #[error("unsupported product definition template: {0}")]
41 UnsupportedProductTemplate(u16),
42
43 #[error("unsupported bitmap indicator: {0}")]
44 UnsupportedBitmapIndicator(u8),
45
46 #[error("unsupported packing width: {0} bits per value")]
47 UnsupportedPackingWidth(u8),
48
49 #[error("unsupported scanning mode: 0b{0:08b}")]
50 UnsupportedScanningMode(u8),
51
52 #[error("unsupported spatial differencing order: {0}")]
53 UnsupportedSpatialDifferencingOrder(u8),
54
55 #[error("data truncated at offset {offset}")]
56 Truncated { offset: u64 },
57
58 #[error("decoded data length mismatch: expected {expected}, got {actual}")]
59 DataLengthMismatch { expected: usize, actual: usize },
60
61 #[error("bitmap indicates missing values but no bitmap section present")]
62 MissingBitmap,
63
64 #[error("{0}")]
65 Other(String),
66}