1use std::fmt;
2
3#[derive(Debug, Clone, PartialEq)]
5#[non_exhaustive]
6pub enum FdarError {
7 InvalidDimension {
9 parameter: &'static str,
10 expected: String,
11 actual: String,
12 },
13 InvalidParameter {
15 parameter: &'static str,
16 message: String,
17 },
18 ComputationFailed {
20 operation: &'static str,
21 detail: String,
22 },
23 InvalidEnumValue { enum_name: &'static str, value: i32 },
25}
26
27impl fmt::Display for FdarError {
28 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
29 match self {
30 FdarError::InvalidDimension {
31 parameter,
32 expected,
33 actual,
34 } => write!(
35 f,
36 "invalid dimension for '{parameter}': expected {expected}, got {actual}"
37 ),
38 FdarError::InvalidParameter { parameter, message } => {
39 write!(f, "invalid parameter '{parameter}': {message}")
40 }
41 FdarError::ComputationFailed { operation, detail } => {
42 write!(f, "{operation} failed: {detail}")
43 }
44 FdarError::InvalidEnumValue { enum_name, value } => {
45 write!(f, "invalid value {value} for enum '{enum_name}'")
46 }
47 }
48 }
49}
50
51impl std::error::Error for FdarError {}