antecedent_core/query/
error.rs1use crate::ids::VariableId;
6
7#[derive(Clone, Debug, Eq, PartialEq, thiserror::Error)]
9#[non_exhaustive]
10pub enum QueryError {
11 #[error("invalid response query: {0}")]
13 InvalidResponse(String),
14 #[error("invalid transport query: {0}")]
16 InvalidTransport(String),
17 #[error("invalid interference query: {0}")]
19 InvalidInterference(String),
20 #[error("treatment and outcome are the same variable {id}")]
22 TreatmentEqualsOutcome {
23 id: VariableId,
25 },
26 #[error("intervention targets {got}, expected treatment {expected}")]
28 InterventionVariableMismatch {
29 expected: VariableId,
31 got: VariableId,
33 },
34 #[error("intervention does not have a unique target variable")]
36 AmbiguousInterventionTarget,
37 #[error("effect modifier overlaps treatment or outcome")]
39 ModifierOverlapsTreatmentOrOutcome,
40 #[error("invalid temporal window [{from}, {until}]")]
42 InvalidTemporalWindow {
43 from: i32,
45 until: i32,
47 },
48 #[error("horizon_steps must be >= 1")]
50 NonPositiveHorizon,
51 #[error("invalid intervention: {0}")]
53 InvalidIntervention(String),
54 #[error("counterfactual query requires at least one outcome")]
56 EmptyCounterfactualOutcomes,
57 #[error("anomaly attribution requires targets")]
59 EmptyAnomalyTargets,
60 #[error("anomaly max_units must be >= 1")]
62 NonPositiveAnomalyLimit,
63 #[error("mediation query requires mediators")]
65 EmptyMediators,
66 #[error("mediator overlaps treatment or outcome")]
68 MediatorOverlapsTreatmentOrOutcome,
69 #[error("conditional effect requires non-empty effect modifiers")]
71 EmptyEffectModifiers,
72 #[error("population selector has no rows")]
74 EmptyPopulationRows,
75 #[error("predicate name must be non-empty")]
77 EmptyPredicateName,
78 #[error("TemporalPolicy::Dynamic has no single treatment offset")]
80 DynamicPolicyHasNoTreatmentOffset,
81 #[error("invalid population time range [{start}, {end})")]
83 InvalidPopulationTimeRange {
84 start: usize,
86 end: usize,
88 },
89 #[error("sequential allocation order is empty")]
91 EmptyAllocationOrder,
92 #[error("sequential allocation order contains duplicate components")]
94 DuplicateAllocationComponent,
95 #[error("Shapley max_exact_components must be >= 1")]
97 NonPositiveShapleyLimit,
98 #[error("Shapley sample / permutation count must be >= 1")]
100 NonPositiveShapleySamples,
101 #[error("max_components / max_targets must be >= 1")]
103 NonPositiveComponentLimit,
104 #[error("mechanism-change detection requires targets")]
106 EmptyMechanismChangeTargets,
107 #[error("significance level must be in (0, 1)")]
109 InvalidSignificanceLevel,
110 #[error("interventional distribution requires at least one outcome")]
112 EmptyDistributionOutcomes,
113 #[error("path max_paths / max_len must be >= 1")]
115 NonPositivePathLimit,
116 #[error("path node overlaps treatment or outcome")]
118 PathNodeOverlapsTreatmentOrOutcome,
119 #[error("distribution conditioning overlaps outcome or intervention")]
121 ConditioningOverlapsOutcomeOrIntervention,
122 #[error("named predicate / custom distribution requires a PopulationRegistry")]
124 PopulationRegistryRequired,
125 #[error("unknown predicate name `{name}`")]
127 UnknownPredicateName {
128 name: std::sync::Arc<str>,
130 },
131 #[error("unknown DistributionRef({id})")]
133 UnknownDistributionRef {
134 id: u32,
136 },
137 #[error("Treated/Untreated population requires a treatment column")]
139 PopulationNeedsTreatment,
140 #[error("Treated/Untreated population requires binary 0/1 treatment")]
142 PopulationNonBinaryTreatment,
143 #[error("population length mismatch: expected {expected}, got {actual}")]
145 PopulationLengthMismatch {
146 expected: usize,
148 actual: usize,
150 },
151 #[error("population row {row} out of range for n={n}")]
153 PopulationRowOutOfRange {
154 row: usize,
156 n: usize,
158 },
159 #[error("Environment target population is not resolved by PopulationRegistry")]
161 PopulationEnvironmentUnsupported,
162 #[error("custom distribution weights must be finite and non-negative")]
164 InvalidPopulationWeights,
165}