use axum::http::StatusCode; use axum::response::{IntoResponse, Response}; #[derive(Debug, thiserror::Error)] pub enum Error { #[error("not found")] NotFound, #[error("gate not satisfied: {0}")] GateBlocked(String), #[error(transparent)] Db(#[from] sqlx::Error), #[error(transparent)] Other(#[from] anyhow::Error), } impl IntoResponse for Error { fn into_response(self) -> Response { let status = match &self { Error::NotFound => StatusCode::NOT_FOUND, Error::GateBlocked(_) => StatusCode::CONFLICT, _ => StatusCode::INTERNAL_SERVER_ERROR, }; (status, self.to_string()).into_response() } } pub type Result = std::result::Result;