1use core::fmt;
2
3#[derive(Debug)]
5pub enum ValidationError {
6 ValueTooLarge {
8 name: &'static str,
10 value: u8,
12 limit: u8,
14 inclusive: bool,
16 },
17}
18
19#[cfg(feature = "std")]
20extern crate std;
21
22#[cfg(feature = "std")]
23impl std::error::Error for ValidationError {}
24
25impl fmt::Display for ValidationError {
26 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
27 match self {
28 ValidationError::ValueTooLarge {
29 name,
30 value,
31 limit,
32 inclusive,
33 } => write!(
34 f,
35 "'{}' value [{}] must be less than (or equal: {}) [{}])",
36 name, value, limit, inclusive
37 ),
38 }
39 }
40}