use thiserror::Error;
#[derive(Debug, Error, PartialEq, Eq)]
pub enum SafeMathError {
#[error("Arithmetic operation resulted in a boundary overflow")]
Overflow = 9000,
#[error("Arithmetic operation resulted in a boundary underflow")]
Underflow = 9001,
#[error("Integer could not be safely casted to the target type")]
ConversionFailed = 9002,
}
#[cfg(all(feature = "anchor", not(feature = "quasar")))]
impl From<SafeMathError> for anchor_lang::prelude::ProgramError {
fn from(e: SafeMathError) -> Self {
Self::Custom(e as u32)
}
}
#[cfg(feature = "quasar")]
impl From<SafeMathError> for quasar_lang::prelude::ProgramError {
fn from(e: SafeMathError) -> Self {
Self::Custom(e as u32)
}
}