use antecedent_core::QueryError;
use antecedent_data::DataError;
use antecedent_prob::ProbError;
use antecedent_stats::StatsError;
use thiserror::Error;
#[derive(Clone, Debug, Error, Eq, PartialEq)]
#[non_exhaustive]
pub enum EstimationError {
#[error(transparent)]
Data(#[from] DataError),
#[error(transparent)]
Stats(#[from] StatsError),
#[error(transparent)]
Prob(#[from] ProbError),
#[error(transparent)]
Query(#[from] QueryError),
#[error("{message}")]
Overlap {
message: &'static str,
},
#[error("{message}")]
IncompatibleEstimand {
message: &'static str,
},
#[error("effect modifiers are not supported on this estimator path")]
EffectModifiers,
#[error("only TargetPopulation::AllObserved is supported on this estimator path")]
TargetPopulation,
#[error("{message}")]
Unsupported {
message: &'static str,
},
}
impl EstimationError {
#[must_use]
pub const fn unsupported(message: &'static str) -> Self {
Self::Unsupported { message }
}
#[must_use]
pub fn data_msg(message: impl Into<String>) -> Self {
Self::Data(DataError::InvalidArgument { message: message.into() })
}
#[must_use]
pub fn stats_msg(message: impl Into<String>) -> Self {
Self::Stats(StatsError::Backend(message.into()))
}
}