Skip to main content

nereids_io/
error.rs

1//! Error types for the nereids-io crate.
2
3/// Errors that can occur during I/O operations.
4#[derive(Debug, thiserror::Error)]
5#[non_exhaustive]
6pub enum IoError {
7    /// File not found or could not be opened.
8    #[error("File not found: {0}: {1}")]
9    FileNotFound(String, #[source] std::io::Error),
10
11    /// Path is not a directory.
12    #[error("Not a directory: {0}")]
13    NotADirectory(String),
14
15    /// TIFF decoding error.
16    #[error("TIFF decode error: {0}")]
17    TiffDecode(String),
18
19    /// Frame dimensions do not match.
20    #[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    /// Array shape error.
29    #[error("Shape mismatch: {0}")]
30    ShapeMismatch(String),
31
32    /// No files matched the given pattern.
33    #[error("No files matching pattern '{pattern}' in directory: {directory}")]
34    NoMatchingFiles { directory: String, pattern: String },
35
36    /// Invalid parameter.
37    #[error("Invalid parameter: {0}")]
38    InvalidParameter(String),
39
40    /// TIFF encoding/writing error.
41    #[error("TIFF encode error: {0}")]
42    TiffEncode(String),
43
44    /// Generic file write error (not TIFF-specific).
45    #[error("Write error: {0}")]
46    WriteError(String),
47
48    /// HDF5 format or access error.
49    #[error("HDF5 error: {0}")]
50    Hdf5Error(String),
51}