use super::types::CtfeError;
use std::fmt;
impl fmt::Display for CtfeError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
CtfeError::DivisionByZero => write!(f, "division by zero"),
CtfeError::IndexOutOfBounds { index, length } => {
write!(f, "index {} out of bounds (length {})", index, length)
}
CtfeError::StackOverflow { depth } => {
write!(f, "stack overflow at depth {}", depth)
}
CtfeError::NonConstant { reason } => write!(f, "non-constant: {}", reason),
CtfeError::Timeout { fuel_used } => {
write!(f, "timeout after {} steps", fuel_used)
}
CtfeError::Overflow { op } => write!(f, "integer overflow in {}", op),
CtfeError::BadProjection { field } => {
write!(f, "cannot project field {} from non-constructor", field)
}
CtfeError::NonExhaustiveMatch => write!(f, "non-exhaustive pattern match"),
}
}
}