use crate::{ParseColorError, ParseInputError, Signal, WaitError};
#[derive(Clone, Debug, thiserror::Error)]
#[error("{0}")]
pub struct InvalidRegexSource(String);
impl From<regex::Error> for InvalidRegexSource {
fn from(err: regex::Error) -> Self {
Self(err.to_string())
}
}
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum Error {
#[error("no command configured")]
MissingCommand,
#[error(transparent)]
Spawn(tastty::Error),
#[error(transparent)]
Send(tastty::Error),
#[error(transparent)]
SendKey(tastty::Error),
#[error(transparent)]
SendPaste(tastty::Error),
#[error(transparent)]
Resize(tastty::Error),
#[error(transparent)]
ExitStatus(tastty::Error),
#[error(transparent)]
Kill(tastty::Error),
#[error(transparent)]
Wait(Box<WaitError>),
#[error(transparent)]
ParseInput(#[from] ParseInputError),
#[error(transparent)]
ParseColor(#[from] ParseColorError),
#[error("terminal session has no child process id")]
MissingProcessId,
#[error("signals are not supported on this platform")]
UnsupportedSignal,
#[error("failed to send signal {signal}: {source}")]
Signal {
signal: Signal,
#[source]
source: std::io::Error,
},
#[error("failed to spawn thread '{name}': {source}")]
ThreadSpawn {
name: &'static str,
#[source]
source: std::io::Error,
},
}
pub type Result<T> = std::result::Result<T, Error>;
impl From<WaitError> for Error {
fn from(error: WaitError) -> Self {
Self::Wait(Box::new(error))
}
}