aboutsummaryrefslogtreecommitdiff
path: root/src/error.rs
blob: c3235f00b8384b5adadb57381771d53956a4da58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use rocket::{
    response::{self, Responder},
    Request,
};
use thiserror::Error;

pub type MyResult<T> = Result<T, MyError>;

#[derive(Debug, Error)]
pub enum MyError {
    #[error("{0}")]
    Anyhow(#[from] anyhow::Error),
    #[error("{0}")]
    Io(#[from] std::io::Error),
}

impl<'r> Responder<'r, 'static> for MyError {
    fn respond_to(self, req: &'r Request<'_>) -> response::Result<'static> {
        format!("{self}").respond_to(req)
    }
}