use std::fmt::{Display, Formatter};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ParseVariableError {
pub msg: String,
pub r#type: VariableError,
}
impl Display for ParseVariableError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}: {}", self.r#type, self.msg)
}
}
impl ParseVariableError {
pub(crate) fn get_not_found_error(s: &str) -> ParseVariableError {
const WEBSITE: &str = " please visit http://xcsp.org/specifications/variables/integer/";
ParseVariableError {
msg: (s.to_owned() + WEBSITE),
r#type: VariableError::NotFoundAsVariable,
}
}
pub(crate) fn get_size_invalid_error(s: &str) -> ParseVariableError {
const WEBSITE: &str = " please visit http://xcsp.org/specifications/variables";
ParseVariableError {
msg: (s.to_owned() + WEBSITE),
r#type: VariableError::SizeInvalid,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum VariableError {
NotFoundAsVariable,
SizeInvalid,
}