adic_shape/
error.rs

1//! Error module for the [adic-shape](crate) crate
2
3use std::{error, fmt, num::TryFromIntError};
4use adic::AdicError;
5
6#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7/// Error from `adic-shape` operations
8pub enum AdicShapeError {
9    /// Error from the `adic` crate
10    AdicError(AdicError),
11    /// Error when dealing with `petgraph`
12    PetGraph,
13    /// Error for configuration problems
14    ImproperConfig(String),
15    /// Error from infinite digits where finite are expected
16    InfiniteDigits,
17    /// Error applying a style to an element
18    StyleError(String),
19    /// Error propagated from [`TryFromIntError`](std::num::TryFromIntError)
20    TryFromIntError,
21}
22
23
24impl fmt::Display for AdicShapeError {
25    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
26        write!(f, "{self:?}")
27    }
28}
29
30impl error::Error for AdicShapeError { }
31
32
33impl From<AdicError> for AdicShapeError {
34    fn from(e: AdicError) -> Self {
35        AdicShapeError::AdicError(e)
36    }
37}
38
39impl From<TryFromIntError> for AdicShapeError {
40    fn from(_: TryFromIntError) -> Self {
41        AdicShapeError::TryFromIntError
42    }
43}