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