//! Executor errors. They preserve stage, operation, command, exit status and //! captured output, and never contain secrets. use std::path::PathBuf; use phoebus_core::CoreError; pub type Result = std::result::Result; #[derive(Debug, thiserror::Error)] pub enum ExecError { #[error("[{stage}] {operation} failed (exit {status}): {program}")] Command { stage: String, operation: String, program: String, status: i32, stdout: String, stderr: String, }, #[error("[{stage}] {operation}: {message}")] Operation { stage: String, operation: String, message: String, }, #[error("command could not be started: {program}: {source}")] Spawn { program: String, #[source] source: std::io::Error, }, #[error("I/O error for {path}: {source}")] Io { path: PathBuf, #[source] source: std::io::Error, }, #[error("missing required tool: {0}")] MissingTool(String), #[error("destructive operation not authorized: {0}")] NotAuthorized(String), #[error("core error: {0}")] Core(#[from] CoreError), } impl ExecError { pub fn io(path: impl Into, source: std::io::Error) -> Self { ExecError::Io { path: path.into(), source, } } pub fn operation(stage: &str, operation: &str, message: impl Into) -> Self { ExecError::Operation { stage: stage.to_string(), operation: operation.to_string(), message: message.into(), } } }