use crate::Dim;
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum BuilderError {
DuplicateDimension(Dim),
WarnNotBelowLimit(Dim),
ZeroLimit(Dim),
NoDimensions,
}
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum ChargeError {
UnknownDimension(Dim),
}
impl core::fmt::Display for BuilderError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::DuplicateDimension(dim) => {
write!(f, "dimension '{}' declared more than once", dim.name())
}
Self::WarnNotBelowLimit(dim) => {
write!(
f,
"warn threshold for '{}' must be strictly less than its limit",
dim.name()
)
}
Self::ZeroLimit(dim) => {
write!(f, "limit for '{}' must be non-zero", dim.name())
}
Self::NoDimensions => {
write!(f, "budget must declare at least one dimension")
}
}
}
}
impl core::fmt::Display for ChargeError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::UnknownDimension(dim) => {
write!(
f,
"dimension '{}' was not declared in this budget",
dim.name()
)
}
}
}
}
#[cfg(feature = "std")]
impl std::error::Error for BuilderError {}
#[cfg(feature = "std")]
impl std::error::Error for ChargeError {}