use std::{
io,
time::Duration,
};
use crate::{
CommandError,
OutputStream,
};
pub(crate) fn spawn_failed(command: &str, source: io::Error) -> CommandError {
CommandError::SpawnFailed {
command: command.to_owned(),
source,
}
}
pub(crate) fn wait_failed(command: &str, source: io::Error) -> CommandError {
CommandError::WaitFailed {
command: command.to_owned(),
source,
}
}
pub(crate) fn kill_failed(command: String, timeout: Duration, source: io::Error) -> CommandError {
CommandError::KillFailed {
command,
timeout,
source,
}
}
pub(crate) fn output_pipe_error(command: &str, stream: OutputStream) -> CommandError {
CommandError::ReadOutputFailed {
command: command.to_owned(),
stream,
source: io::Error::other(format!("{} pipe was not created", stream.as_str())),
}
}