1use tidepool_repr::DataConId;
2use std::error::Error;
3use std::fmt;
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}
31
32impl fmt::Display for BridgeError {
33 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
34 match self {
35 BridgeError::UnknownDataCon(id) => write!(f, "Unknown DataConId: {:?}", id),
36 BridgeError::UnknownDataConName(name) => write!(f, "Unknown DataCon name: {}", name),
37 BridgeError::ArityMismatch { con, expected, got } => {
38 write!(
39 f,
40 "Arity mismatch for DataCon {:?}: expected {}, got {}",
41 con, expected, got
42 )
43 }
44 BridgeError::TypeMismatch { expected, got } => {
45 write!(f, "Type mismatch: expected {}, got {}", expected, got)
46 }
47 BridgeError::UnsupportedType(ty) => write!(f, "Unsupported type: {}", ty),
48 }
49 }
50}
51
52impl Error for BridgeError {}