1use core::fmt;
2
3#[derive(Clone, Copy, Debug, PartialEq, Eq)]
5pub enum IntegerError {
6 DivisionByZero,
8 ArithmeticOverflow { operation: &'static str },
10}
11
12impl fmt::Display for IntegerError {
13 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
14 match self {
15 Self::DivisionByZero => {
16 formatter.write_str("integer operation requires a non-zero divisor")
17 },
18 Self::ArithmeticOverflow { operation } => {
19 write!(
20 formatter,
21 "integer operation overflowed while computing {operation}"
22 )
23 },
24 }
25 }
26}
27
28impl std::error::Error for IntegerError {}