Skip to main content

yscv_imgproc/
error.rs

1use thiserror::Error;
2use yscv_tensor::TensorError;
3
4#[derive(Debug, Clone, PartialEq, Eq, Error)]
5pub enum ImgProcError {
6    #[error("invalid image shape: expected rank {expected_rank}, got {got:?}")]
7    InvalidImageShape {
8        expected_rank: usize,
9        got: Vec<usize>,
10    },
11    #[error("invalid channel count: expected {expected}, got {got}")]
12    InvalidChannelCount { expected: usize, got: usize },
13    #[error("invalid output size: height={height}, width={width}; both must be > 0")]
14    InvalidSize { height: usize, width: usize },
15    #[error(
16        "invalid normalization params for {expected_channels} channels: mean_len={mean_len}, std_len={std_len}"
17    )]
18    InvalidNormalizationParams {
19        expected_channels: usize,
20        mean_len: usize,
21        std_len: usize,
22    },
23    #[error("std must be non-zero at channel {channel}")]
24    ZeroStdAtChannel { channel: usize },
25    #[error("invalid block size: {block_size}; must be odd and > 0")]
26    InvalidBlockSize { block_size: usize },
27    #[error("invalid output dimensions: height={out_h}, width={out_w}; both must be > 0")]
28    InvalidOutputDimensions { out_h: usize, out_w: usize },
29    #[error("shape mismatch: expected {expected:?}, got {got:?}")]
30    ShapeMismatch {
31        expected: Vec<usize>,
32        got: Vec<usize>,
33    },
34    #[error("I/O error: {message}")]
35    Io { message: String },
36    #[error("unsupported image format: {path}")]
37    UnsupportedFormat { path: String },
38    #[error("image decode error: {message}")]
39    ImageDecode { message: String },
40    #[error("image encode error: {message}")]
41    ImageEncode { message: String },
42    #[error(transparent)]
43    Tensor(#[from] TensorError),
44}