1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use std::{
    error::Error,
    fmt::{Debug, Display, Formatter},
};

use crate::{NyarError, NyarErrorKind};

impl Error for NyarError {}

impl Error for NyarErrorKind {}
impl Debug for NyarError {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        Debug::fmt(self.kind.as_ref(), f)
    }
}
impl Debug for NyarErrorKind {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::Missing(e) => Debug::fmt(e, f),
            Self::Duplicate(e) => Debug::fmt(e, f),
            Self::Runtime(e) => Debug::fmt(e, f),
            Self::Parsing(e) => Debug::fmt(e, f),
            Self::Custom(e) => Debug::fmt(e, f),
        }
    }
}

impl Display for NyarError {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        Display::fmt(self.kind.as_ref(), f)
    }
}

impl Display for NyarErrorKind {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::Missing(e) => Display::fmt(e, f),
            Self::Duplicate(e) => Display::fmt(e, f),
            Self::Runtime(e) => Display::fmt(e, f),
            Self::Parsing(e) => Display::fmt(e, f),
            Self::Custom(e) => Display::fmt(e, f),
        }
    }
}