1use ndarray::ShapeError;
2use std::convert::From;
3use thiserror::Error;
4
5#[derive(Error, Debug)]
6pub enum ModelError {
7 #[error("Incompatible dimensions: {dim1:?}, and {dim2:?}")]
8 Dimensions { dim1: Vec<usize>, dim2: Vec<usize> },
9
10 #[error("Key error: {0}")]
11 KeyError(String),
12
13 #[error("Invalid configuration: {0}")]
14 Configuration(String),
15
16 #[error("Invalid parameter: Requested parameter {0} not found.")]
17 InvalidParameter(String),
18
19 #[error("Gradient not found: {0} not found in gradients hash map.")]
20 GradientNotFound(String),
21
22 #[error("Cache error: {0}")]
23 CacheError(String),
24
25 #[error("Convergence failed: {0}")]
26 Convergence(String),
27
28 #[error("Dimensionality error: {0}")]
29 DimensionalityError(String),
30
31 #[error("Shape error: {0}")]
32 ShapeError(String),
33
34 #[error("Invalid value: {0}")]
35 InvalidValue(String),
36}
37
38impl From<ShapeError> for ModelError {
40 fn from(err: ShapeError) -> Self {
41 ModelError::ShapeError(format!("{}", err))
42 }
43}