use core::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SafeMathError {
Overflow,
DivisionByZero,
InfiniteOrNaN,
#[cfg(feature = "derive")]
NotImplemented,
}
impl fmt::Display for SafeMathError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
SafeMathError::Overflow => write!(f, "arithmetic overflow"),
SafeMathError::DivisionByZero => write!(f, "division by zero"),
SafeMathError::InfiniteOrNaN => write!(f, "infinite or NaN value"),
#[cfg(feature = "derive")]
SafeMathError::NotImplemented => write!(f, "operation not implemented"),
}
}
}
impl std::error::Error for SafeMathError {}
impl From<SafeMathError> for () {
fn from(_: SafeMathError) -> Self {}
}