use compliance_core::CoreError; use thiserror::Error; #[derive(Error, Debug)] pub enum AgentError { #[error(transparent)] Core(#[from] CoreError), #[error("Database error: {0}")] Database(#[from] mongodb::error::Error), #[error("Git error: {0}")] Git(#[from] git2::Error), #[error("HTTP error: {0}")] Http(#[from] reqwest::Error), #[error("JSON error: {0}")] Json(#[from] serde_json::Error), #[error("IO error: {0}")] Io(#[from] std::io::Error), #[error("Scheduler error: {0}")] Scheduler(String), #[error("Configuration error: {0}")] Config(String), #[error("{0}")] Other(String), } impl From for axum::http::StatusCode { fn from(err: AgentError) -> Self { match err { AgentError::Core(CoreError::NotFound(_)) => axum::http::StatusCode::NOT_FOUND, _ => axum::http::StatusCode::INTERNAL_SERVER_ERROR, } } }