proc_ctl/
error.rs

1use crate::types::ProtocolPort;
2use thiserror::Error;
3
4/// A result type to return `ProcCtlError`s
5pub type ProcCtlResult<T> = Result<T, ProcCtlError>;
6
7/// Custom error type for proc-ctl
8#[derive(Error, Debug)]
9pub enum ProcCtlError {
10    /// An error occurred while searching process information
11    #[cfg(target_os = "linux")]
12    #[error("process error")]
13    ProcessError(#[from] procfs::ProcError),
14
15    /// An error occurred while searching process information
16    #[cfg(any(target_os = "windows", target_os = "macos"))]
17    #[error("process error")]
18    ProcessError(String),
19
20    /// The user made an error using the API, a more specific error message will be provided
21    #[error("configuration error {0}")]
22    ConfigurationError(String),
23
24    /// Fewer ports than expected were found on the matched process
25    #[error("too few ports, got {0:?} but expected {1}")]
26    TooFewPorts(Vec<ProtocolPort>, usize),
27
28    /// Too few children were found on the matched process
29    #[error("too few children, got {0} but expected {1}")]
30    TooFewChildren(usize, usize),
31}