pub type Result = std::result::Result; #[derive(Debug, thiserror::Error)] pub enum Error { #[error("IO error: {0}")] IO(#[from] std::io::Error), #[error("Config error: {0}")] Toml(#[from] toml::de::Error), #[error("Request error: {0}")] Reqwest(#[from] reqwest::Error), #[error("Invalid HTTP method")] Method, #[error("Axum error: {0}")] Axum(#[from] axum::Error), #[error("Route not found: {0}")] RouteNotFound(axum::http::Uri), #[error("Service not found: {0}")] ServiceNotFound(String), } impl axum::response::IntoResponse for Error { fn into_response(self) -> axum::response::Response { use axum::http::StatusCode; let status = match self { Self::RouteNotFound(_) | Self::ServiceNotFound(_) => StatusCode::NOT_FOUND, _ => StatusCode::INTERNAL_SERVER_ERROR, }; (status, self.to_string()).into_response() } }