pub type Result = std::result::Result; #[derive(thiserror::Error, Debug)] pub enum Error { #[error("Axum error: {0}")] Axum(#[from] axum::Error), #[error("Database error: {0}")] Sqlx(#[from] sqlx::Error), #[error("Migration error: {0}")] Migration(#[from] sqlx::migrate::MigrateError), #[error("API error: {0}")] Api(#[from] crate::api::error::Error), #[error("Authorization error: {0}")] Auth(#[from] crate::auth::error::Error), } impl axum::response::IntoResponse for Error { fn into_response(self) -> axum::response::Response { use axum::http::StatusCode; // TODO: implement [rfc7807](https://www.rfc-editor.org/rfc/rfc7807.html) match self { Self::Api(err) => err.into_response(), Self::Auth(err) => err.into_response(), err => (StatusCode::INTERNAL_SERVER_ERROR, err.to_string()).into_response(), } } }