use vision_calibration_core::Error as CoreError;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum Error {
#[error("invalid input: {reason}")]
InvalidInput { reason: String },
#[error("insufficient data: need {need}, got {got}")]
InsufficientData { need: usize, got: usize },
#[error("singular matrix or degenerate configuration")]
Singular,
#[error("numerical failure: {0}")]
Numerical(String),
#[error(transparent)]
Core(#[from] CoreError),
}
impl Error {
pub(crate) fn invalid_input(reason: impl Into<String>) -> Self {
Self::InvalidInput {
reason: reason.into(),
}
}
pub(crate) fn numerical(msg: impl Into<String>) -> Self {
Self::Numerical(msg.into())
}
}
impl From<anyhow::Error> for Error {
fn from(e: anyhow::Error) -> Self {
Self::Numerical(e.to_string())
}
}