ggplot_error/error/
error_std.rs

1use super::*;
2
3macro_rules! error_wrap {
4    ($t:ty => $name:ident) => {
5        impl From<$t> for GGError {
6            fn from(e: $t) -> Self {
7                Self::$name(e)
8            }
9        }
10    };
11    ($($t:ty => $name:ident),+ $(,)?) => (
12        $(error_wrap!($t=>$name);)+
13    );
14}
15
16error_wrap![
17    std::io::Error  => IOError,
18    std::fmt::Error => FormatError,
19];
20
21impl From<std::num::ParseIntError> for GGError {
22    fn from(e: std::num::ParseIntError) -> Self {
23        Self::SyntaxError(e.to_string())
24    }
25}
26
27impl From<Infallible> for GGError {
28    fn from(_: Infallible) -> Self {
29        Self::Unreachable
30    }
31}
32
33impl From<()> for GGError {
34    fn from(_: ()) -> Self {
35        Self::Unreachable
36    }
37}