varpro/model/
errors.rs

1use thiserror::Error as ThisError;
2
3/// Errors pertaining to use errors of the [crate::model::SeparableModel].
4#[derive(Debug, Clone, ThisError, PartialEq, Eq)]
5pub enum ModelError {
6    /// Base functions are expected to return a vector the same length as the location argument.
7    /// A function did not adhere to that rule.
8    #[error(
9        "Base function gave vector of length {}, but expected output length was {}",
10        actual_length,
11        expected_length
12    )]
13    UnexpectedFunctionOutput {
14        /// the expected length
15        expected_length: usize,
16        /// the actual length
17        actual_length: usize,
18    },
19
20    /// Indicates an evaluation for a parameter was requested that is not part of the model parameters
21    #[error("Parameter '{}' is not in model", parameter)]
22    ParameterNotInModel {
23        /// the parameter that was not part of the model
24        parameter: String,
25    },
26
27    /// Indicates that the given derivative index is out of bounds.
28    #[error("Index {} for derivative is out of bounds", index)]
29    DerivativeIndexOutOfBounds {
30        /// the index of the derivative out of bounds
31        index: usize,
32    },
33
34    /// It was tried to evaluate a model with an incorrect number of parameters
35    #[error("Model expects {} parameters, but got {}", expected, actual)]
36    IncorrectParameterCount {
37        /// the number of parameters that are required for the model
38        expected: usize,
39        /// the given number of parameters
40        actual: usize,
41    },
42}