blob: 04d7e38afcaa684e8ab262f4d293db73fc81619b (
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
|
use std::fmt::Display;
use rocket::{
response::{self, Responder},
Request,
};
use thiserror::Error;
pub type MyResult<T> = Result<T, MyError>;
#[derive(Debug, Error)]
pub enum MyError {
Anyhow(#[from] anyhow::Error),
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)
}
}
impl Display for MyError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{self:?}")
}
}
|