use std::error::Error;
use std::fmt;
use super::PolicyLocation;
use super::Sensitivity;
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq, Eq)]
#[must_use]
pub enum PolicyError {
EmptyFieldName {
location: PolicyLocation,
},
EmptyFixedReplacement {
location: PolicyLocation,
level: Sensitivity,
},
OutputLimitTooLarge {
maximum: usize,
},
#[cfg(feature = "serde")]
SerdePayloadLimitTooLarge {
maximum: usize,
},
}
impl fmt::Display for PolicyError {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::EmptyFieldName { location } => {
write!(formatter, "field name is empty after canonicalization in {location}",)
}
Self::EmptyFixedReplacement { location, level } => write!(
formatter,
"fixed mask replacement for {level:?} sensitivity is empty in {location}",
),
#[cfg(feature = "serde")]
Self::SerdePayloadLimitTooLarge { maximum } => write!(
formatter,
"Serde payload limit {maximum} exceeds this platform's addressable collection capacity",
),
Self::OutputLimitTooLarge { maximum } => write!(
formatter,
"output limit {maximum} exceeds this platform's addressable collection capacity",
),
}
}
}
impl Error for PolicyError {}