scirs2_integrate/ode/
error.rs1use std::error::Error;
4use std::fmt;
5
6#[derive(Debug)]
8pub enum ODEError {
9 Convergence,
11 StepSizeTooSmall,
13 MaxStepsExceeded,
15 NumericalInstability,
17 InvalidInput(String),
19 General(String),
21}
22
23impl fmt::Display for ODEError {
24 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
25 match self {
26 ODEError::Convergence => write!(f, "Failed to converge to a solution"),
27 ODEError::StepSizeTooSmall => write!(f, "Step size became too small"),
28 ODEError::MaxStepsExceeded => write!(f, "Exceeded maximum number of steps"),
29 ODEError::NumericalInstability => {
30 write!(f, "Encountered numerical instability (NaN or Inf)")
31 }
32 ODEError::InvalidInput(msg) => write!(f, "Invalid input: {}", msg),
33 ODEError::General(msg) => write!(f, "Error: {}", msg),
34 }
35 }
36}
37
38impl Error for ODEError {}