use std::fmt::Display; use rocket::{ response::{self, Responder}, Request, }; use thiserror::Error; pub type MyResult = Result; #[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:?}") } }