vision_calibration_optim/
error.rs1use vision_calibration_core::Error as CoreError;
4
5#[derive(Debug, thiserror::Error)]
7#[non_exhaustive]
8pub enum Error {
9 #[error("invalid input: {reason}")]
11 InvalidInput { reason: String },
12
13 #[error("insufficient data: need {need}, got {got}")]
15 InsufficientData { need: usize, got: usize },
16
17 #[error("singular matrix or degenerate configuration")]
19 Singular,
20
21 #[error("numerical failure: {0}")]
23 Numerical(String),
24
25 #[error(transparent)]
27 Core(#[from] CoreError),
28}
29
30impl Error {
31 pub(crate) fn invalid_input(reason: impl Into<String>) -> Self {
33 Self::InvalidInput {
34 reason: reason.into(),
35 }
36 }
37
38 pub(crate) fn numerical(msg: impl Into<String>) -> Self {
40 Self::Numerical(msg.into())
41 }
42}
43
44impl From<anyhow::Error> for Error {
45 fn from(e: anyhow::Error) -> Self {
46 Self::Numerical(e.to_string())
47 }
48}