1#[derive(Debug, thiserror::Error)]
5#[non_exhaustive]
6pub enum IoError {
7 #[error("File not found: {0}: {1}")]
9 FileNotFound(String, #[source] std::io::Error),
10
11 #[error("Not a directory: {0}")]
13 NotADirectory(String),
14
15 #[error("TIFF decode error: {0}")]
17 TiffDecode(String),
18
19 #[error("Dimension mismatch at frame {frame}: expected ({ew}×{eh}), got ({gw}×{gh})",
21 ew = expected.0, eh = expected.1, gw = got.0, gh = got.1)]
22 DimensionMismatch {
23 expected: (u32, u32),
24 got: (u32, u32),
25 frame: usize,
26 },
27
28 #[error("Shape mismatch: {0}")]
30 ShapeMismatch(String),
31
32 #[error("No files matching pattern '{pattern}' in directory: {directory}")]
34 NoMatchingFiles { directory: String, pattern: String },
35
36 #[error("Invalid parameter: {0}")]
38 InvalidParameter(String),
39
40 #[error("TIFF encode error: {0}")]
42 TiffEncode(String),
43
44 #[error("Write error: {0}")]
46 WriteError(String),
47
48 #[error("HDF5 error: {0}")]
50 Hdf5Error(String),
51
52 #[error("Inconsistent DAQ chunks in directory {directory}: {details}")]
57 ChunkMismatch { directory: String, details: String },
58
59 #[error(
61 "Bad pixel value {value} at flat index {index} of frame {frame} in '{file}': \
62 raw counts must be finite and >= 0. For corrupt readout pixels, mask them \
63 per acquisition with detect_bad_pixels(); to clamp negative values to zero \
64 use the clip pixel policy (PixelValuePolicy::ClipToZero); for pre-normalized \
65 transmission data use the allow policy (PixelValuePolicy::Allow)."
66 )]
67 BadPixelValue {
68 file: String,
69 frame: usize,
70 index: usize,
71 value: f64,
72 },
73}