csaps/
errors.rs

1use thiserror::Error;
2use ndarray::ShapeError;
3
4
5/// Enum provides error types
6#[derive(Error, Debug)]
7pub enum CsapsError {
8    /// Any errors when the given input data is invalid
9    #[error("Invalid input: {0}")]
10    InvalidInputData(String),
11
12    /// Error occurs when reshape from 2-d representation for n-d data has failed
13    #[error("Cannot reshape 2-d array with shape {input_shape:?} \
14             to {}-d array with shape {output_shape:?} by axis {axis}. Error: {source}",
15            output_shape.len())]
16    ReshapeFrom2d {
17        input_shape: Vec<usize>,
18        output_shape: Vec<usize>,
19        axis: usize,
20        #[source]
21        source: ShapeError,
22    },
23
24    /// Error occurs when reshape to 2-d representation for n-d data has failed
25    #[error("Cannot reshape {}-d array with shape {input_shape:?} by axis {axis} \
26             to 2-d array with shape {output_shape:?}. Error: {source}",
27            input_shape.len())]
28    ReshapeTo2d {
29        input_shape: Vec<usize>,
30        output_shape: Vec<usize>,
31        axis: usize,
32        #[source]
33        source: ShapeError,
34    },
35}