Skip to main content

antecedent_model/
error.rs

1//! Model-layer errors.
2//!
3//! SPDX-License-Identifier: MIT OR Apache-2.0
4
5use antecedent_data::DataError;
6use antecedent_graph::GraphError;
7use antecedent_stats::StatsError;
8use thiserror::Error;
9
10/// Errors from compiling, fitting, or sampling causal models.
11#[derive(Clone, Debug, Error, Eq, PartialEq)]
12pub enum ModelError {
13    /// Graph / shape inconsistency.
14    #[error("model shape error: {message}")]
15    Shape {
16        /// Context.
17        message: String,
18    },
19    /// Graph is cyclic or has no topological order.
20    #[error("not a DAG: {message}")]
21    NotDag {
22        /// Context.
23        message: String,
24    },
25    /// Mechanism missing for a node.
26    #[error("missing mechanism for node {node}")]
27    MissingMechanism {
28        /// Dense node index.
29        node: u32,
30    },
31    /// Unsupported intervention or mechanism family.
32    #[error("unsupported: {message}")]
33    Unsupported {
34        /// Context.
35        message: String,
36    },
37    /// Numerical failure.
38    #[error("numerical error: {message}")]
39    Numerical {
40        /// Context.
41        message: String,
42    },
43    /// Graph error passthrough.
44    #[error(transparent)]
45    Graph(#[from] GraphError),
46    /// Data error passthrough.
47    #[error(transparent)]
48    Data(#[from] DataError),
49    /// Stats error passthrough.
50    #[error(transparent)]
51    Stats(#[from] StatsError),
52}