use core::fmt;
use ruint::BaseConvertError;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ParseSignedError {
Ruint(ruint::ParseError),
IntegerOverflow,
}
impl From<ruint::ParseError> for ParseSignedError {
fn from(err: ruint::ParseError) -> Self {
match err {
ruint::ParseError::BaseConvertError(BaseConvertError::Overflow) => {
Self::IntegerOverflow
}
_ => Self::Ruint(err),
}
}
}
#[cfg(feature = "std")]
impl std::error::Error for ParseSignedError {}
impl fmt::Display for ParseSignedError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Ruint(err) => write!(f, "Parsing Error: {err}"),
Self::IntegerOverflow => f.write_str("number does not fit in the integer size"),
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct BigIntConversionError;
#[cfg(feature = "std")]
impl std::error::Error for BigIntConversionError {}
impl fmt::Display for BigIntConversionError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("output of range integer conversion attempted")
}
}