1use std::fmt::Debug;
4
5#[derive(Debug, thiserror::Error)]
6pub enum Error {
7 #[error(transparent)]
8 ResidualBlockBuildingError(#[from] ResidualBlockBuildingError),
9 #[error(transparent)]
10 SolverOptionsBuildingError(#[from] SolverOptionsBuildingError),
11 #[error(transparent)]
12 CurveFitProblemBuildError(#[from] CurveFitProblemBuildError),
13 #[error(transparent)]
14 NllsProblemError(#[from] NllsProblemError),
15}
16
17#[derive(Debug, thiserror::Error)]
18pub enum ResidualBlockBuildingError {
19 #[error("No cost function set for residual block")]
20 MissingCost,
21 #[error("No parameters set for residual block")]
22 MissingParameters,
23 #[error(transparent)]
24 ParameterBlockStorageError(#[from] ParameterBlockStorageError),
25}
26
27#[derive(Debug, thiserror::Error)]
28pub enum ParameterBlockStorageError {
29 #[error("Index of ParameterBlock out of bounds: {index} >= {len}")]
30 IndexOutOfBounds { index: usize, len: usize },
31}
32
33#[derive(Debug, thiserror::Error)]
34pub enum SolverOptionsBuildingError {
35 #[error("SolverOptions is invalid: {0}")]
36 Invalid(String),
37}
38
39#[derive(Debug, thiserror::Error)]
41pub enum CurveFitProblemBuildError {
42 #[error("Data arrays x, y, or inverse_error have different lengths")]
43 DataSizesDontMatch,
44 #[error("Cost function is missed")]
45 FuncMissed,
46 #[error("Independent parameter x is missed")]
47 XMissed,
48 #[error("Dependent parameter y is missed")]
49 YMissed,
50 #[error("Initial parameters' guess are missed")]
51 ParametersMissed,
52 #[error("Lower boundary size doesn't match the number of parameters")]
53 LowerBoundarySizeMismatch,
54 #[error("Upper boundary size doesn't match the number of parameters")]
55 UpperBoundarySizeMismatch,
56 #[error("Constant parameter index is out of bounds: {0}")]
57 ParameterBlockStorageError(#[from] ParameterBlockStorageError),
58}
59
60#[derive(Debug, thiserror::Error)]
62pub enum NllsProblemError {
63 #[error("No residual blocks added to the problem")]
64 NoResidualBlocks,
65}