use axum::http::StatusCode; use axum::response::{IntoResponse, Response}; /// Wraps anyhow::Error into an axum-compatible error response. pub struct AppError(pub anyhow::Error); impl IntoResponse for AppError { fn into_response(self) -> Response { tracing::error!("{:#}", self.0); (StatusCode::INTERNAL_SERVER_ERROR, self.0.to_string()).into_response() } } impl> From for AppError { fn from(err: E) -> Self { AppError(err.into()) } } /// Convenience type for route handlers. pub type AppResult = Result;