#[cfg(feature = "std")]
extern crate std;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum ArithmeticError {
DivisionByZero,
ResultTooLarge,
ResultTooSmall,
PrecisionLoss,
}
impl core::fmt::Display for ArithmeticError {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self {
ArithmeticError::DivisionByZero => write!(f, "arithmetic error: division by zero"),
ArithmeticError::ResultTooLarge => write!(f, "arithmetic error: result is too large to be represented"),
ArithmeticError::ResultTooSmall => write!(f, "arithmetic error: result is too small to be represented"),
ArithmeticError::PrecisionLoss => write!(f, "arithmetic error: loss of precision"),
}
}
}
#[cfg(feature = "std")]
impl std::error::Error for ArithmeticError {}