use thiserror::Error; use alloy::providers::PendingTransactionError; use alloy::transports::TransportErrorKind; #[derive(Debug, Error)] pub enum AppError { #[error("invalid request: {0}")] InvalidRequest(String), #[error("redaction failed: {0}")] Redaction(String), #[error("inference failed: {0}")] Inference(String), #[error("medical enrichment failed: {0}")] Medical(String), #[error("audit failed: {0}")] Audit(String), #[error(transparent)] Http(#[from] reqwest::Error), #[error(transparent)] Json(#[from] serde_json::Error), #[error(transparent)] Io(#[from] std::io::Error), #[error(transparent)] Chrono(#[from] chrono::ParseError), #[error(transparent)] Other(#[from] anyhow::Error), } impl From for AppError { fn from(e: axum::Error) -> Self { AppError::Other(anyhow::anyhow!(e)) } } impl From> for AppError { fn from(e: RpcError) -> Self { AppError::Other(anyhow::anyhow!(e)) } } impl From for AppError { fn from(e: PendingTransactionError) -> Self { AppError::Other(anyhow::anyhow!(e)) } } use alloy::rpc::json_rpc::RpcError;