use crate::prelude::*; use axum::{http::StatusCode, response::IntoResponse}; #[derive(Debug)] pub struct Error(pub Box); impl IntoResponse for Error { fn into_response(self) -> axum::http::Response { error!("webserver error: {:?}", self.0); ( StatusCode::INTERNAL_SERVER_ERROR, format!("internal server error: {}", self.0), ) .into_response() } } // This enables using `?` on functions that return `Result<_, anyhow::Error>` // to turn them into `Result<_, AppError>`. That way you don't need to do that // manually. impl From for Error where E: Into>, { fn from(err: E) -> Self { Self(err.into()) } }