1use core::fmt;
4
5#[derive(Debug, Clone, PartialEq, Eq)]
7pub enum Error {
8 OutOfRange {
10 context: &'static str,
12 },
13 CoefficientCountMismatch {
15 got: usize,
17 expected: usize,
19 },
20 DivisionByZero,
22 ZeroIterations,
24}
25
26impl fmt::Display for Error {
27 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
28 match self {
29 Self::OutOfRange { context } => {
30 write!(f, "value out of field range in {context}")
31 }
32 Self::CoefficientCountMismatch { got, expected } => {
33 write!(
34 f,
35 "coefficient count mismatch: got {got}, expected {expected}"
36 )
37 }
38 Self::DivisionByZero => write!(f, "division by zero in field"),
39 Self::ZeroIterations => {
40 write!(f, "iteration count must be positive")
41 }
42 }
43 }
44}
45
46impl core::error::Error for Error {}