use core::fmt;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum ArithmeticError {
Overflow,
Underflow,
DivisionByZero,
ScaleExceeded,
NegativeSqrt,
LogOfZero,
LogOfNegative,
}
impl fmt::Display for ArithmeticError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Overflow => write!(f, "arithmetic overflow"),
Self::Underflow => write!(f, "arithmetic underflow"),
Self::DivisionByZero => write!(f, "division by zero"),
Self::ScaleExceeded => write!(f, "scale exceeds maximum precision"),
Self::NegativeSqrt => write!(f, "square root of negative number"),
Self::LogOfZero => write!(f, "logarithm of zero"),
Self::LogOfNegative => write!(f, "logarithm of negative number"),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum ParseError {
Empty,
InvalidCharacter,
MultipleDecimalPoints,
OutOfRange,
}
impl fmt::Display for ParseError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Empty => write!(f, "empty string"),
Self::InvalidCharacter => write!(f, "invalid character"),
Self::MultipleDecimalPoints => write!(f, "multiple decimal points"),
Self::OutOfRange => write!(f, "value out of range"),
}
}
}