aboutsummaryrefslogtreecommitdiff
path: root/src/error.rs
blob: 9a83afff830f41f48800cbea6a92fae66b109d93 (plain)
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
#[derive(Debug, thiserror::Error)]
pub enum ServiceError {
    #[error("hyper error")]
    Hyper(hyper::Error),
    #[error("unknown host")]
    NoHost,
    #[error("can't connect to the backend")]
    CantConnect,
    #[error("not found")]
    NotFound,
    #[error("io error: {0}")]
    Io(std::io::Error),
    #[error("bad range")]
    BadRange,
    #[error("bad utf8")]
    BadUtf8,
    #[error("ohh. i didn't expect that this error can be generated.")]
    Other,
}

impl From<std::io::Error> for ServiceError {
    fn from(e: std::io::Error) -> Self {
        Self::Io(e)
    }
}
impl From<std::str::Utf8Error> for ServiceError {
    fn from(_: std::str::Utf8Error) -> Self {
        Self::BadUtf8
    }
}