use capsula_core::error::CapsulaError;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum CommandHookError {
#[error("Command cannot be empty")]
EmptyCommand,
#[error("Failed to execute command '{command}': {source}")]
ExecutionFailed {
command: String,
#[source]
source: std::io::Error,
},
#[error("Command output contains invalid UTF-8: {message}")]
InvalidUtf8 { message: String },
#[error("Command '{command}' exited with status {status}")]
NonZeroExit { command: String, status: i32 },
#[error("Failed to serialize command hook: {0}")]
Serialization(#[from] serde_json::Error),
}
impl From<CommandHookError> for CapsulaError {
fn from(err: CommandHookError) -> Self {
Self::HookFailed {
hook: "capture-command".to_string(),
source: Box::new(err),
}
}
}