Skip to main content

scirs2_ndimage/
error.rs

1//! Error types for the ndimage module
2//!
3//! This module provides error types for the ndimage module functions.
4
5use scirs2_core::error::CoreError;
6use thiserror::Error;
7
8/// Error type for ndimage operations
9#[derive(Error, Debug)]
10pub enum NdimageError {
11    /// Invalid input data
12    #[error("Invalid input: {0}")]
13    InvalidInput(String),
14
15    /// Dimension error
16    #[error("Dimension mismatch: {0}")]
17    DimensionError(String),
18
19    /// Implementation error
20    #[error("Implementation error: {0}")]
21    ImplementationError(String),
22
23    /// Computation error
24    #[error("Computation error: {0}")]
25    ComputationError(String),
26
27    /// Filter error
28    #[error("Filter error: {0}")]
29    FilterError(String),
30
31    /// Interpolation error
32    #[error("Interpolation error: {0}")]
33    InterpolationError(String),
34
35    /// Measurement error
36    #[error("Measurement error: {0}")]
37    MeasurementError(String),
38
39    /// Morphology error
40    #[error("Morphology error: {0}")]
41    MorphologyError(String),
42
43    /// Not implemented error
44    #[error("Not implemented: {0}")]
45    NotImplementedError(String),
46
47    /// Processing error
48    #[error("Processing error: {0}")]
49    ProcessingError(String),
50
51    /// Core error (propagated from scirs2-core)
52    #[error("{0}")]
53    CoreError(#[from] CoreError),
54
55    /// IO error
56    #[error("IO error: {0}")]
57    IoError(#[from] std::io::Error),
58
59    /// Shape building error
60    #[error("Shape error: {0}")]
61    ShapeError(#[from] scirs2_core::ndarray::ShapeError),
62
63    /// Format error
64    #[error("Format error: {0}")]
65    FormatError(#[from] std::fmt::Error),
66
67    /// GPU not available error
68    #[error("GPU not available: {0}")]
69    GpuNotAvailable(String),
70
71    /// Configuration error
72    #[error("Configuration error: {0}")]
73    ConfigurationError(String),
74
75    /// Memory error
76    #[error("Memory error: {0}")]
77    MemoryError(String),
78
79    /// Other error
80    #[error("Error: {0}")]
81    Other(String),
82}
83
84// The #[from] attribute in the CoreError variant handles the conversion automatically
85
86/// Result type for ndimage operations
87pub type NdimageResult<T> = std::result::Result<T, NdimageError>;