1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//! Probability / inference errors.
//!
//! SPDX-License-Identifier: MIT OR Apache-2.0
use core::fmt;
/// Errors from prior construction, posterior storage, or inference backends.
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum ProbError {
/// Shape / dimension mismatch.
Shape {
/// Context.
message: &'static str,
},
/// Invalid prior or configuration.
InvalidPrior {
/// Context.
message: &'static str,
},
/// Inference failed to converge or produce a usable approximation.
Inference {
/// Context.
message: &'static str,
},
/// Numerical failure (singular Hessian, separation, etc.).
Numerical {
/// Context.
message: String,
},
/// Missing required diagnostics for a reported posterior.
MissingDiagnostics {
/// Context.
message: String,
},
}
impl fmt::Display for ProbError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Shape { message } => write!(f, "shape error: {message}"),
Self::InvalidPrior { message } => write!(f, "invalid prior: {message}"),
Self::Inference { message } => write!(f, "inference error: {message}"),
Self::Numerical { message } => write!(f, "numerical error: {message}"),
Self::MissingDiagnostics { message } => {
write!(f, "missing diagnostics: {message}")
}
}
}
}
impl std::error::Error for ProbError {}