use core::fmt;
#[derive(Debug)]
pub enum ValidationError {
ValueTooLarge {
name: &'static str,
value: u8,
limit: u8,
inclusive: bool,
},
}
#[cfg(feature = "std")]
extern crate std;
#[cfg(feature = "std")]
impl std::error::Error for ValidationError {}
impl fmt::Display for ValidationError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
ValidationError::ValueTooLarge {
name,
value,
limit,
inclusive,
} => write!(
f,
"'{}' value [{}] must be less than (or equal: {}) [{}])",
name, value, limit, inclusive
),
}
}
}