phoebus_os/installer-rs/crates/phoebus-executor/src/error.rs
Phoebus 38214ea9e7 chore: import Phoebus OS installer and Rust migration
Initial public import of the proven Bash installer (installer/) and the production Rust workspace (installer-rs/). The reference ISO, build output and local agent transcripts are gitignored.

Verified: installer/tests/run_tests.sh and cargo test --workspace both pass.
2026-09-20 02:07:33 -07:00

68 lines
1.6 KiB
Rust

//! 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<T> = std::result::Result<T, ExecError>;
#[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<PathBuf>, source: std::io::Error) -> Self {
ExecError::Io {
path: path.into(),
source,
}
}
pub fn operation(stage: &str, operation: &str, message: impl Into<String>) -> Self {
ExecError::Operation {
stage: stage.to_string(),
operation: operation.to_string(),
message: message.into(),
}
}
}