1use std::fmt;
2
3#[derive(Debug, Clone)]
5pub enum Error {
6 NoLaws,
8 ValueCountMismatch { expected: usize, got: usize },
10 InvalidTolerance(f64),
12 InvalidTime(f64),
14}
15
16impl fmt::Display for Error {
17 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18 match self {
19 Self::NoLaws => write!(f, "no conservation laws registered"),
20 Self::ValueCountMismatch { expected, got } => {
21 write!(f, "expected {expected} values, got {got}")
22 }
23 Self::InvalidTolerance(v) => write!(f, "invalid tolerance: {v}"),
24 Self::InvalidTime(v) => write!(f, "invalid time: {v}"),
25 }
26 }
27}
28
29impl std::error::Error for Error {}
30
31pub type Result<T> = std::result::Result<T, Error>;