use std::{path::PathBuf, process::ExitStatus, str::Utf8Error};
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("Unable to attach to stdin of command \"{command}\"")]
CommandAttachToStdin {
command: String,
},
#[error("The command \"{command}\" could not be started in the background:\n{source}")]
CommandBackground {
command: String,
source: std::io::Error,
},
#[error("The command \"{command}\" could not be executed:\n{source}")]
CommandExec {
command: String,
source: std::io::Error,
},
#[error(
"The command \"{command}\" exited with non-zero status code \"{exit_status}\":\nstderr:\n{stderr}"
)]
CommandNonZero {
command: String,
exit_status: ExitStatus,
stderr: String,
},
#[error("Unable to write to stdin of command \"{command}\"")]
CommandWriteToStdin {
command: String,
source: std::io::Error,
},
#[error("Unable to to find executable \"{command}\"")]
ExecutableNotFound {
command: String,
source: which::Error,
},
#[error("I/O error while {context}:\n{source}")]
Io {
context: &'static str,
source: std::io::Error,
},
#[error("I/O error at {path} while {context}:\n{source}")]
IoPath {
path: PathBuf,
context: &'static str,
source: std::io::Error,
},
#[error("Password hash error while {context}: {source}")]
PasswordHash {
context: String,
source: yescrypt::password_hash::Error,
},
#[error("Converting a byte vector to a string failed while {context}:\n{source}")]
Utf8String {
context: String,
source: Utf8Error,
},
}