1use std::error::Error;
2use std::fmt;
3use tidepool_repr::DataConId;
4
5#[derive(Debug, Clone, PartialEq, Eq)]
7pub enum BridgeError {
8 UnknownDataCon(DataConId),
10 UnknownDataConName(String),
12 ArityMismatch {
14 con: DataConId,
16 expected: usize,
18 got: usize,
20 },
21 TypeMismatch {
23 expected: String,
25 got: String,
27 },
28 UnsupportedType(String),
30 InternalError(String),
32}
33
34impl fmt::Display for BridgeError {
35 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
36 match self {
37 BridgeError::UnknownDataCon(id) => write!(f, "Unknown DataConId: {:?}", id),
38 BridgeError::UnknownDataConName(name) => write!(f, "Unknown DataCon name: {}", name),
39 BridgeError::ArityMismatch { con, expected, got } => {
40 write!(
41 f,
42 "Arity mismatch for DataCon {:?}: expected {}, got {}",
43 con, expected, got
44 )
45 }
46 BridgeError::TypeMismatch { expected, got } => {
47 write!(f, "Type mismatch: expected {}, got {}", expected, got)
48 }
49 BridgeError::UnsupportedType(ty) => write!(f, "Unsupported type: {}", ty),
50 BridgeError::InternalError(msg) => write!(f, "Internal error: {}", msg),
51 }
52 }
53}
54
55impl Error for BridgeError {}