#[derive(Debug)]
pub enum CausalError {
NodeNotFound(String),
CycleDetected,
DimensionMismatch,
InsufficientData,
NoCausalPath,
NumericalError(String),
}
impl std::fmt::Display for CausalError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
CausalError::NodeNotFound(name) => {
write!(f, "causal: node '{}' not found in graph", name)
}
CausalError::CycleDetected => {
write!(f, "causal: cycle detected — graph is not a DAG")
}
CausalError::DimensionMismatch => {
write!(
f,
"causal: sample dimension does not match number of variables"
)
}
CausalError::InsufficientData => {
write!(f, "causal: insufficient data for the requested computation")
}
CausalError::NoCausalPath => {
write!(
f,
"causal: no directed causal path between the specified nodes"
)
}
CausalError::NumericalError(msg) => {
write!(f, "causal: numerical error — {}", msg)
}
}
}
}
impl std::error::Error for CausalError {}