Skip to main content

google_dns_rs/
error.rs

1use std::{fmt, io};
2
3#[derive(Debug)]
4pub enum Error {
5    Http(ureq::Error),
6    IO(io::Error),
7}
8
9impl From<ureq::Error> for Error {
10    fn from(e: ureq::Error) -> Self {
11        Self::Http(e)
12    }
13}
14
15impl std::error::Error for Error {}
16
17impl From<io::Error> for Error {
18    fn from(e: io::Error) -> Self {
19        Self::IO(e)
20    }
21}
22
23impl fmt::Display for Error {
24    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
25        match self {
26            Self::Http(e) => write!(f, "Http Error: {}", e),
27            Self::IO(e) => write!(f, "{}", e),
28        }
29    }
30}