1use core::fmt;
2use std::error::Error;
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
6pub enum GeodeError {
7 EmptyTypeVector,
9 IndexOutOfBounds,
11 ArithmeticOverflow,
13 DivisionNotExact,
15 InvalidInput,
17}
18
19impl fmt::Display for GeodeError {
20 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
21 match self {
22 Self::EmptyTypeVector => {
23 formatter.write_str("type vectors must contain at least one component")
24 },
25 Self::IndexOutOfBounds => formatter.write_str("type vector index is out of bounds"),
26 Self::ArithmeticOverflow => {
27 formatter.write_str("geode arithmetic overflowed its exact integer representation")
28 },
29 Self::DivisionNotExact => formatter.write_str("geode division was not exact"),
30 Self::InvalidInput => formatter.write_str("geode input violated a crate invariant"),
31 }
32 }
33}
34
35impl Error for GeodeError {}