pub mod xcsp3_core {
use crate::errors::parse_constraint_error::xcsp3_core::ParseConstraintError;
use crate::errors::parse_domain_error::xcsp3_core::ParseDomainError;
use crate::errors::parse_objectives_error::xcsp3_core::ParseObjectivesError;
use crate::errors::parse_variable_error::ParseVariableError;
use quick_xml::DeError;
use std::fmt::{Display, Formatter};
#[derive(Debug, Clone)]
pub enum Xcsp3Error {
ParseDomainError(ParseDomainError),
ParseVariableError(ParseVariableError),
ParseConstraintError(ParseConstraintError),
ParseObjectivesError(ParseObjectivesError),
ReadXmlError(DeError),
}
impl Display for Xcsp3Error {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}",
match self {
Xcsp3Error::ParseDomainError(e) => e.to_string(),
Xcsp3Error::ParseVariableError(e) => e.to_string(),
Xcsp3Error::ParseConstraintError(e) => e.to_string(),
Xcsp3Error::ParseObjectivesError(e) => e.to_string(),
Xcsp3Error::ReadXmlError(e) => e.to_string(),
}
)
}
}
impl Xcsp3Error {
pub fn get_read_xml_error(err: DeError) -> Xcsp3Error {
Xcsp3Error::ReadXmlError(err)
}
pub fn get_constraint_slide_error(s: &str) -> Xcsp3Error {
Xcsp3Error::ParseConstraintError(ParseConstraintError::get_slide_error(s))
}
pub fn get_objective_scope_error(s: &str) -> Xcsp3Error {
Xcsp3Error::ParseObjectivesError(ParseObjectivesError::get_scope_error(s))
}
pub fn get_objective_coeffs_error(s: &str) -> Xcsp3Error {
Xcsp3Error::ParseObjectivesError(ParseObjectivesError::get_coeffs_error(s))
}
pub fn get_objective_type_error(s: &str) -> Xcsp3Error {
Xcsp3Error::ParseObjectivesError(ParseObjectivesError::get_type_error(s))
}
pub fn get_objective_target_error(s: &str) -> Xcsp3Error {
Xcsp3Error::ParseObjectivesError(ParseObjectivesError::get_target_error(s))
}
pub fn get_constraint_element_error(s: &str) -> Xcsp3Error {
Xcsp3Error::ParseConstraintError(ParseConstraintError::get_element_error(s))
}
pub fn get_constraint_count_error(s: &str) -> Xcsp3Error {
Xcsp3Error::ParseConstraintError(ParseConstraintError::get_count_error(s))
}
pub fn get_constraint_no_overlap_error(s: &str) -> Xcsp3Error {
Xcsp3Error::ParseConstraintError(ParseConstraintError::get_no_overlap_error(s))
}
pub fn get_constraint_cumulative_error(s: &str) -> Xcsp3Error {
Xcsp3Error::ParseConstraintError(ParseConstraintError::get_cumulative_error(s))
}
pub fn get_constraint_cardinality_error(s: &str) -> Xcsp3Error {
Xcsp3Error::ParseConstraintError(ParseConstraintError::get_cardinality_error(s))
}
pub fn get_constraint_sum_error(s: &str) -> Xcsp3Error {
Xcsp3Error::ParseConstraintError(ParseConstraintError::get_sum_error(s))
}
pub fn get_constraint_group_error(s: &str) -> Xcsp3Error {
Xcsp3Error::ParseConstraintError(ParseConstraintError::get_group_error(s))
}
pub fn get_constraint_expression_error(s: &str) -> Xcsp3Error {
Xcsp3Error::ParseConstraintError(ParseConstraintError::get_expression_error(s))
}
pub fn get_constraint_channel_error(s: &str) -> Xcsp3Error {
Xcsp3Error::ParseConstraintError(ParseConstraintError::get_channel_error(s))
}
pub fn get_constraint_extension_error(s: &str) -> Xcsp3Error {
Xcsp3Error::ParseConstraintError(ParseConstraintError::get_extension_error(s))
}
pub fn get_constraint_scope_not_found_error(s: &str) -> Xcsp3Error {
Xcsp3Error::ParseConstraintError(ParseConstraintError::get_scope_not_found_error(s))
}
pub fn get_constraint_regular_transitions_error(s: &str) -> Xcsp3Error {
Xcsp3Error::ParseConstraintError(ParseConstraintError::get_regular_transitions_error(s))
}
pub fn get_constraint_list_of_values_error(s: &str) -> Xcsp3Error {
Xcsp3Error::ParseConstraintError(ParseConstraintError::get_list_of_values_error(s))
}
pub fn get_domain_integer_error(s: &str) -> Xcsp3Error {
Xcsp3Error::ParseDomainError(ParseDomainError::get_integer_error(s))
}
pub fn get_domain_interval_error(s: &str) -> Xcsp3Error {
Xcsp3Error::ParseDomainError(ParseDomainError::get_interval_error(s))
}
pub fn get_domain_for_error(s: &str) -> Xcsp3Error {
Xcsp3Error::ParseDomainError(ParseDomainError::get_domain_for_error(s))
}
pub fn get_variable_not_found_error(s: &str) -> Xcsp3Error {
Xcsp3Error::ParseVariableError(ParseVariableError::get_not_found_error(s))
}
pub fn get_variable_size_invalid_error(s: &str) -> Xcsp3Error {
Xcsp3Error::ParseVariableError(ParseVariableError::get_size_invalid_error(s))
}
}
}