1use faer::{
2 linalg::svd::SvdError,
3 sparse::{CreationError, FaerError, linalg::LuError},
4};
5
6use crate::Id;
7
8#[derive(thiserror::Error, Debug)]
10#[cfg_attr(not(feature = "unstable-exhaustive"), non_exhaustive)]
11pub enum TextualError {
12 #[error("No guess was given for point {label}")]
14 MissingGuess {
15 label: String,
17 },
18 #[error("You gave a guess for points which weren't defined: {labels:?}")]
20 UnusedGuesses {
21 labels: Vec<String>,
23 },
24 #[error("You referred to the point {label} but it was never defined")]
26 UndefinedPoint {
27 label: String,
29 },
30}
31
32#[derive(thiserror::Error, Debug)]
34#[cfg_attr(not(feature = "unstable-exhaustive"), non_exhaustive)]
35pub enum NonLinearSystemError {
36 #[error("ID {0} not found")]
38 NotFound(Id),
39 #[error(
41 "There should be exactly 1 guess per variable, but you supplied {labels} variables and must {guesses} guesses"
42 )]
43 WrongNumberGuesses {
44 labels: usize,
46 guesses: usize,
48 },
49 #[error(
51 "Constraint {constraint_id} references variable {variable} but no such variable appears in your initial guesses."
52 )]
53 MissingGuess {
54 constraint_id: usize,
56 variable: Id,
58 },
59 #[error("Could not create matrix: {error}")]
61 FaerMatrix {
62 #[from]
64 error: CreationError,
65 },
66 #[error("Something went wrong in faer: {error}")]
68 Faer {
69 #[from]
71 error: FaerError,
72 },
73 #[error("Something went wrong doing matrix solves in faer: {error}")]
75 FaerSolve {
76 #[from]
78 error: LuError,
79 },
80 #[error("Something went wrong doing SVD in faer")]
82 FaerSvd(SvdError),
83 #[error("Could not find a solution in the allowed number of iterations")]
86 DidNotConverge,
87 #[error("Cannot solve an empty system")]
89 EmptySystemNotAllowed,
90}