vision_calibration_pipeline/
error.rs1use vision_calibration_core::Error as CoreError;
4use vision_calibration_linear::Error as LinearError;
5use vision_calibration_optim::Error as OptimError;
6
7#[derive(Debug, thiserror::Error)]
9#[non_exhaustive]
10pub enum Error {
11 #[error("invalid input: {reason}")]
13 InvalidInput { reason: String },
14
15 #[error("insufficient data: need {need}, got {got}")]
17 InsufficientData { need: usize, got: usize },
18
19 #[error("session resource not available: {resource}")]
21 NotAvailable { resource: &'static str },
22
23 #[error("numerical failure: {0}")]
25 Numerical(String),
26
27 #[error("serialization error: {0}")]
29 Serde(#[from] serde_json::Error),
30
31 #[error(transparent)]
33 Core(#[from] CoreError),
34
35 #[error(transparent)]
37 Linear(#[from] LinearError),
38
39 #[error(transparent)]
41 Optim(#[from] OptimError),
42}
43
44impl Error {
45 pub(crate) fn invalid_input(reason: impl Into<String>) -> Self {
47 Self::InvalidInput {
48 reason: reason.into(),
49 }
50 }
51
52 pub(crate) fn numerical(msg: impl Into<String>) -> Self {
54 Self::Numerical(msg.into())
55 }
56
57 pub(crate) fn not_available(resource: &'static str) -> Self {
59 Self::NotAvailable { resource }
60 }
61}
62
63impl From<anyhow::Error> for Error {
66 fn from(e: anyhow::Error) -> Self {
67 Self::Numerical(e.to_string())
68 }
69}