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)]
12#[non_exhaustive]
13pub enum ModelError {
14    /// Graph / shape inconsistency.
15    #[error("model shape error: {message}")]
16    Shape {
17        /// Context.
18        message: String,
19    },
20    /// Graph is cyclic or has no topological order.
21    #[error("not a DAG: {message}")]
22    NotDag {
23        /// Context.
24        message: String,
25    },
26    /// Mechanism missing for a node.
27    #[error("missing mechanism for node {node}")]
28    MissingMechanism {
29        /// Dense node index.
30        node: u32,
31    },
32    /// Unsupported intervention or mechanism family.
33    #[error("unsupported: {message}")]
34    Unsupported {
35        /// Context.
36        message: String,
37    },
38    /// Numerical failure.
39    #[error("numerical error: {message}")]
40    Numerical {
41        /// Context.
42        message: String,
43    },
44    /// Graph error passthrough.
45    #[error(transparent)]
46    Graph(#[from] GraphError),
47    /// Data error passthrough.
48    #[error(transparent)]
49    Data(#[from] DataError),
50    /// Stats error passthrough.
51    #[error(transparent)]
52    Stats(#[from] StatsError),
53}