use creusot_std::prelude::{Clone, DeepModel, PartialEq, *};
#[derive(Clone, Copy, PartialEq, Eq, Debug, DeepModel)]
#[non_exhaustive]
pub enum Error {
Range,
TooManyVariables {
requested: usize,
},
DimensionMismatch {
expected: usize,
found: usize,
},
ClockOutOfRange {
clock: usize,
variables: usize,
},
NegativeConstant {
value: i32,
},
InvalidMaxBounds {
variable: usize,
value: i32,
},
}
#[cfg(not(creusot))]
impl core::fmt::Display for Error {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match *self {
Error::Range => f.write_str("bound constant outside the representable range"),
Error::TooManyVariables { requested } => {
write!(f, "too many clock variables requested: {requested}")
}
Error::DimensionMismatch { expected, found } => {
write!(
f,
"dimension mismatch: expected {expected} variables, found {found}"
)
}
Error::ClockOutOfRange { clock, variables } => {
write!(
f,
"clock index {clock} out of range for {variables} variables"
)
}
Error::NegativeConstant { value } => {
write!(f, "negative reset value {value}")
}
Error::InvalidMaxBounds { variable, value } => {
write!(f, "invalid maximal constant {value} for clock x{variable}")
}
}
}
}
#[cfg(not(creusot))]
impl std::error::Error for Error {}