1use thiserror::Error;
4
5#[derive(Error, Debug)]
7pub enum Error {
8 #[error("I/O error: {0}")]
9 Io(#[from] std::io::Error),
10
11 #[error("Invalid raster dimensions: {width}x{height}")]
12 InvalidDimensions { width: usize, height: usize },
13
14 #[error("Index out of bounds: ({row}, {col}) in raster of size ({rows}, {cols})")]
15 IndexOutOfBounds {
16 row: usize,
17 col: usize,
18 rows: usize,
19 cols: usize,
20 },
21
22 #[error("Raster size mismatch: expected ({er}, {ec}), got ({ar}, {ac})")]
23 SizeMismatch {
24 er: usize,
25 ec: usize,
26 ar: usize,
27 ac: usize,
28 },
29
30 #[error("CRS mismatch: {0} vs {1}")]
31 CrsMismatch(String, String),
32
33 #[error("Unsupported data type: {0}")]
34 UnsupportedDataType(String),
35
36 #[error("No data value not set")]
37 NoDataNotSet,
38
39 #[error("GDAL error: {0}")]
40 #[cfg(feature = "gdal")]
41 Gdal(String),
42
43 #[error("Invalid parameter: {name} = {value} ({reason})")]
44 InvalidParameter {
45 name: &'static str,
46 value: String,
47 reason: String,
48 },
49
50 #[error("Algorithm error: {0}")]
51 Algorithm(String),
52
53 #[error("{0}")]
54 Other(String),
55}
56
57#[cfg(feature = "gdal")]
58impl From<gdal::errors::GdalError> for Error {
59 fn from(e: gdal::errors::GdalError) -> Self {
60 Error::Gdal(e.to_string())
61 }
62}
63
64pub type Result<T> = std::result::Result<T, Error>;