#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum ConvertError {
Overflow,
NotFinite,
}
impl core::fmt::Display for ConvertError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::Overflow => f.write_str("decimal conversion overflow"),
Self::NotFinite => f.write_str("decimal conversion from non-finite float"),
}
}
}
#[cfg(feature = "std")]
impl std::error::Error for ConvertError {}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum ParseError {
Empty,
SignOnly,
LeadingZero,
OverlongFractional,
ScientificNotation,
InvalidChar,
OutOfRange,
MissingDigits,
}
impl core::fmt::Display for ParseError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let msg = match self {
Self::Empty => "empty input",
Self::SignOnly => "sign with no digits",
Self::LeadingZero => "redundant leading zero in integer part",
Self::OverlongFractional => "fractional part exceeds SCALE digits",
Self::ScientificNotation => "scientific notation not accepted",
Self::InvalidChar => "invalid character",
Self::OutOfRange => "value out of representable range",
Self::MissingDigits => "decimal point with no adjacent digits",
};
f.write_str(msg)
}
}
#[cfg(feature = "std")]
impl std::error::Error for ParseError {}