Files
pruefwerk/compliance-agent/src/error.rs
T
sharang 80eb7f462c
CI / Check (push) Skipped
CI / Detect Changes (push) Successful in 3s
CI / Deploy Docs (push) Skipped
CI / Deploy MCP (push) Skipped
CI / Deploy Dashboard (push) Successful in 5m32s
CI / Deploy Agent (push) Successful in 6m3s
feat(ingest): password-protected archives; 7z and rar refused clearly (#370) (#388)
2026-09-25 09:59:17 +00:00

56 lines
1.4 KiB
Rust

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(transparent)]
Secret(#[from] crate::secrets::SecretError),
#[error("Dynamic-execution error: {0}")]
Exec(#[from] werkbank_exec::ExecError),
/// An uploaded archive is password-protected and no password is set.
#[error("the archive is password-protected; set its password on the target")]
ArchivePasswordRequired,
/// The password set for an uploaded archive does not open it.
#[error("the archive password set on the target does not open it")]
ArchivePasswordWrong,
#[error("{0}")]
Other(String),
}
impl From<AgentError> 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,
}
}
}