antecedent_validate/
error.rs1use antecedent_data::DataError;
6use antecedent_discovery::DiscoveryError;
7use antecedent_estimate::EstimationError;
8use antecedent_prob::ProbError;
9use antecedent_stats::StatsError;
10use thiserror::Error;
11
12#[derive(Clone, Debug, Error, Eq, PartialEq)]
14#[non_exhaustive]
15pub enum ValidationError {
16 #[error(transparent)]
18 Data(#[from] DataError),
19 #[error(transparent)]
21 Estimation(#[from] EstimationError),
22 #[error(transparent)]
24 Stats(#[from] StatsError),
25 #[error(transparent)]
27 Prob(#[from] ProbError),
28 #[error(transparent)]
30 Discovery(#[from] DiscoveryError),
31 #[error("{message}")]
33 NotApplicable {
34 message: &'static str,
36 },
37}
38
39impl ValidationError {
40 #[must_use]
42 pub fn data_msg(message: impl Into<String>) -> Self {
43 Self::Data(DataError::InvalidArgument { message: message.into() })
44 }
45
46 #[must_use]
48 pub fn estimation_msg(message: impl Into<String>) -> Self {
49 Self::Estimation(EstimationError::stats_msg(message))
50 }
51}