use {
num_derive::FromPrimitive,
gemachain_program::{decode_error::DecodeError, program_error::ProgramError},
thiserror::Error,
};
#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]
pub enum MathError {
#[error("Calculation overflowed the destination number")]
Overflow,
#[error("Calculation underflowed the destination number")]
Underflow,
}
impl From<MathError> for ProgramError {
fn from(e: MathError) -> Self {
ProgramError::Custom(e as u32)
}
}
impl<T> DecodeError<T> for MathError {
fn type_of() -> &'static str {
"Math Error"
}
}