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)]
14pub enum ValidationError {
15 #[error(transparent)]
17 Data(#[from] DataError),
18 #[error(transparent)]
20 Estimation(#[from] EstimationError),
21 #[error(transparent)]
23 Stats(#[from] StatsError),
24 #[error(transparent)]
26 Prob(#[from] ProbError),
27 #[error(transparent)]
29 Discovery(#[from] DiscoveryError),
30 #[error("{message}")]
32 NotApplicable {
33 message: &'static str,
35 },
36}
37
38impl ValidationError {
39 #[must_use]
41 pub fn data_msg(message: impl Into<String>) -> Self {
42 Self::Data(DataError::InvalidArgument { message: message.into() })
43 }
44
45 #[must_use]
47 pub fn estimation_msg(message: impl Into<String>) -> Self {
48 Self::Estimation(EstimationError::stats_msg(message))
49 }
50}