deep_causality/errors/
assumption_error.rs

1/*
2 * SPDX-License-Identifier: MIT
3 * Copyright (c) "2025" . The DeepCausality Authors and Contributors. All Rights Reserved.
4 */
5
6//!
7//! Error type for assumption checking.
8//!
9use std::error::Error;
10use std::fmt;
11
12#[derive(Debug, Clone, PartialEq, Eq, Hash)]
13pub enum AssumptionError {
14    /// Error returned when verification is attempted on a model with no assumptions.
15    NoAssumptionsDefined,
16    ///Error returned when verification is attempted without data i.e. empty collection.
17    NoDataToTestDefined,
18    ///Error to capture the specific failed assumption
19    AssumptionFailed(String),
20    /// Wraps an error that occurred during the execution of an assumption function.
21    EvaluationFailed(String),
22}
23
24impl Error for AssumptionError {}
25
26impl fmt::Display for AssumptionError {
27    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
28        match self {
29            AssumptionError::NoAssumptionsDefined => {
30                write!(f, "Model has no assumptions to verify")
31            }
32            AssumptionError::NoDataToTestDefined => {
33                write!(f, "No Data to test provided")
34            }
35            AssumptionError::AssumptionFailed(a) => {
36                write!(f, "Assumption failed: {a}")
37            }
38            AssumptionError::EvaluationFailed(msg) => {
39                write!(f, "Failed to evaluate assumption: {msg}")
40            }
41        }
42    }
43}