#[derive(serde::Serialize, Debug, thiserror::Error)]
pub enum ProcessError {
#[error("failed to {action} process: {source}")]
CommandFailed {
action: &'static str,
#[source]
#[serde(serialize_with = "crate::error::std_io_error_to_string")]
source: Box<dyn std::error::Error + Send + Sync + 'static>,
},
#[error("insufficient privilege to {action}: {source}")]
PermissionDenied {
action: &'static str,
#[source]
#[serde(serialize_with = "crate::error::std_io_error_to_string")]
source: Box<dyn std::error::Error + Send + Sync + 'static>,
},
#[error("no matching server process found for {query}")]
NoSuchProcess { query: String },
#[error("{operation} exceeded {elapsed:?}; PIDs still running: {leftovers:?}")]
TerminationTimeout {
operation: &'static str,
elapsed: std::time::Duration,
leftovers: Vec<u32>,
},
}
pub type Result<T> = std::result::Result<T, ProcessError>;