use_series/error.rs
1use core::fmt;
2use std::error::Error;
3
4/// Errors returned by checked progression helpers.
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
6pub enum SeriesError {
7 /// The requested progression calculation overflowed `i128`.
8 Overflow {
9 /// The operation that overflowed.
10 operation: &'static str,
11 },
12}
13
14impl fmt::Display for SeriesError {
15 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
16 match self {
17 Self::Overflow { operation } => {
18 write!(
19 formatter,
20 "series operation overflowed i128 while computing {operation}"
21 )
22 },
23 }
24 }
25}
26
27impl Error for SeriesError {}