use core::fmt;
#[derive(Clone, Debug, PartialEq)]
pub enum SpecialError {
Domain(String),
Convergence {
function: &'static str,
iterations: usize,
},
}
impl fmt::Display for SpecialError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Domain(msg) => write!(f, "domain error: {msg}"),
Self::Convergence {
function,
iterations,
} => {
write!(
f,
"{function} did not converge after {iterations} iterations"
)
}
}
}
}
impl From<SpecialError> for numra_core::NumraError {
fn from(e: SpecialError) -> Self {
numra_core::NumraError::Special(e.to_string())
}
}