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}
18
19impl fmt::Display for ArithmeticError {
20 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
21 match self {
22 Self::Overflow => write!(f, "arithmetic overflow"),
23 Self::Underflow => write!(f, "arithmetic underflow"),
24 Self::DivisionByZero => write!(f, "division by zero"),
25 Self::ScaleExceeded => write!(f, "scale exceeds maximum precision"),
26 }
27 }
28}
29
30#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
32pub enum ParseError {
33 Empty,
35 InvalidCharacter,
37 MultipleDecimalPoints,
39 OutOfRange,
41}
42
43impl fmt::Display for ParseError {
44 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
45 match self {
46 Self::Empty => write!(f, "empty string"),
47 Self::InvalidCharacter => write!(f, "invalid character"),
48 Self::MultipleDecimalPoints => write!(f, "multiple decimal points"),
49 Self::OutOfRange => write!(f, "value out of range"),
50 }
51 }
52}