nyar_error/errors/
display.rs

1use std::{
2    error::Error,
3    fmt::{Debug, Display, Formatter},
4};
5
6use crate::{NyarError, NyarErrorKind};
7
8impl Error for NyarError {}
9
10impl Error for NyarErrorKind {}
11impl Debug for NyarError {
12    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
13        Debug::fmt(self.kind.as_ref(), f)
14    }
15}
16impl Debug for NyarErrorKind {
17    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
18        match self {
19            Self::Missing(e) => Debug::fmt(e, f),
20            Self::Duplicate(e) => Debug::fmt(e, f),
21            Self::Runtime(e) => Debug::fmt(e, f),
22            Self::Parsing(e) => Debug::fmt(e, f),
23            Self::Custom(e) => Debug::fmt(e, f),
24        }
25    }
26}
27
28impl Display for NyarError {
29    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
30        Display::fmt(self.kind.as_ref(), f)
31    }
32}
33
34impl Display for NyarErrorKind {
35    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
36        match self {
37            Self::Missing(e) => Display::fmt(e, f),
38            Self::Duplicate(e) => Display::fmt(e, f),
39            Self::Runtime(e) => Display::fmt(e, f),
40            Self::Parsing(e) => Display::fmt(e, f),
41            Self::Custom(e) => Display::fmt(e, f),
42        }
43    }
44}