1use core::fmt;
4use serde::{Deserialize, Serialize};
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
8pub enum ArithmeticError {
9 Overflow,
11 Underflow,
13 DivisionByZero,
15 ScaleExceeded,
17 NegativeSqrt,
19 LogOfZero,
21 LogOfNegative,
23}
24
25impl fmt::Display for ArithmeticError {
26 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
27 match self {
28 Self::Overflow => write!(f, "arithmetic overflow"),
29 Self::Underflow => write!(f, "arithmetic underflow"),
30 Self::DivisionByZero => write!(f, "division by zero"),
31 Self::ScaleExceeded => write!(f, "scale exceeds maximum precision"),
32 Self::NegativeSqrt => write!(f, "square root of negative number"),
33 Self::LogOfZero => write!(f, "logarithm of zero"),
34 Self::LogOfNegative => write!(f, "logarithm of negative number"),
35 }
36 }
37}
38
39#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
41pub enum ParseError {
42 Empty,
44 InvalidCharacter,
46 MultipleDecimalPoints,
48 OutOfRange,
50}
51
52impl fmt::Display for ParseError {
53 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
54 match self {
55 Self::Empty => write!(f, "empty string"),
56 Self::InvalidCharacter => write!(f, "invalid character"),
57 Self::MultipleDecimalPoints => write!(f, "multiple decimal points"),
58 Self::OutOfRange => write!(f, "value out of range"),
59 }
60 }
61}