Skip to main content

uncertain_numerics/
error.rs

1use core::fmt;
2
3/// Errors raised while constructing probabilistic numerical results.
4#[derive(Debug, Clone, Copy, PartialEq)]
5pub enum PosteriorError {
6    /// The posterior mean is not finite.
7    NonFiniteMean,
8    /// The posterior variance is not finite.
9    NonFiniteVariance,
10    /// The posterior variance is negative.
11    NegativeVariance,
12}
13
14impl fmt::Display for PosteriorError {
15    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
16        match self {
17            Self::NonFiniteMean => write!(f, "posterior mean must be finite"),
18            Self::NonFiniteVariance => write!(f, "posterior variance must be finite"),
19            Self::NegativeVariance => write!(f, "posterior variance must be non-negative"),
20        }
21    }
22}
23
24impl std::error::Error for PosteriorError {}