libtigen/
error.rs

1use std::fmt::Display;
2
3#[derive(Debug)]
4pub struct DecodingError(pub String);
5
6impl Display for DecodingError {
7    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
8        f.write_fmt(format_args!("{}", self))
9    }
10}
11
12impl std::error::Error for DecodingError {}
13
14#[derive(Debug)]
15pub enum Error {
16    Decoding(DecodingError),
17    Templating(tera::Error),
18    IO(std::io::Error),
19    Nom(String),
20}
21
22impl From<DecodingError> for Error {
23    fn from(err: DecodingError) -> Self {
24        Self::Decoding(err)
25    }
26}
27
28impl From<tera::Error> for Error {
29    fn from(err: tera::Error) -> Self {
30        Self::Templating(err)
31    }
32}
33
34impl From<std::io::Error> for Error {
35    fn from(err: std::io::Error) -> Self {
36        Self::IO(err)
37    }
38}
39
40impl Display for Error {
41    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
42        f.write_fmt(format_args!("{}", self))
43    }
44}
45
46impl std::error::Error for Error {}