add sbot process stats function, struct and error variants
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
//! Custom error type for `peach-stats`.
|
||||
|
||||
use probes::ProbeError;
|
||||
use std::{error, fmt, io::Error as IoError};
|
||||
use std::{error, fmt, io::Error as IoError, str::Utf8Error};
|
||||
|
||||
/// Custom error type encapsulating all possible errors when retrieving system
|
||||
/// statistics.
|
||||
@ -17,6 +17,10 @@ pub enum StatsError {
|
||||
MemStat(ProbeError),
|
||||
/// Failed to retrieve system uptime.
|
||||
Uptime(IoError),
|
||||
/// Systemctl command returned an error.
|
||||
Systemctl(IoError),
|
||||
/// Failed to interpret sequence of `u8` as a string.
|
||||
Utf8String(Utf8Error),
|
||||
}
|
||||
|
||||
impl error::Error for StatsError {}
|
||||
@ -39,6 +43,12 @@ impl fmt::Display for StatsError {
|
||||
StatsError::Uptime(ref source) => {
|
||||
write!(f, "Failed to retrieve system uptime: {}", source)
|
||||
}
|
||||
StatsError::Systemctl(ref source) => {
|
||||
write!(f, "Systemctl command returned an error: {}", source)
|
||||
}
|
||||
StatsError::Utf8String(ref source) => {
|
||||
write!(f, "Failed to convert stdout to string: {}", source)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user