remove snafu
This commit is contained in:
@ -1,30 +1,43 @@
|
||||
use std::{error, io};
|
||||
use std::io;
|
||||
|
||||
use jsonrpc_core::{types::error::Error, ErrorCode};
|
||||
use probes::ProbeError;
|
||||
use snafu::Snafu;
|
||||
|
||||
pub type BoxError = Box<dyn error::Error>;
|
||||
|
||||
#[derive(Debug, Snafu)]
|
||||
#[snafu(visibility(pub(crate)))]
|
||||
#[derive(Debug)]
|
||||
pub enum StatError {
|
||||
#[snafu(display("Failed to retrieve CPU statistics: {}", source))]
|
||||
ReadCpuStat { source: ProbeError },
|
||||
|
||||
#[snafu(display("Failed to retrieve disk usage statistics: {}", source))]
|
||||
ReadDiskUsage { source: ProbeError },
|
||||
|
||||
#[snafu(display("Failed to retrieve load average statistics: {}", source))]
|
||||
ReadLoadAvg { source: ProbeError },
|
||||
|
||||
#[snafu(display("Failed to retrieve memory statistics: {}", source))]
|
||||
ReadMemStat { source: ProbeError },
|
||||
|
||||
#[snafu(display("Failed to retrieve system uptime: {}", source))]
|
||||
ReadUptime { source: io::Error },
|
||||
}
|
||||
|
||||
impl std::fmt::Display for StatError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match *self {
|
||||
StatError::ReadCpuStat { ref source } => {
|
||||
write!(f, "Failed to retrieve CPU statistics: {}", source)
|
||||
}
|
||||
StatError::ReadDiskUsage { ref source } => {
|
||||
write!(f, "Failed to retrieve disk usage statistics: {}", source)
|
||||
}
|
||||
StatError::ReadLoadAvg { ref source } => {
|
||||
write!(f, "Failed to retrieve load average statistics: {}", source)
|
||||
}
|
||||
StatError::ReadMemStat { ref source } => {
|
||||
write!(f, "Failed to retrieve memory statistics: {}", source)
|
||||
}
|
||||
StatError::ReadUptime { ref source } => {
|
||||
write!(f, "Failed to retrieve system uptime: {}", source)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<StatError> for Error {
|
||||
fn from(err: StatError) -> Self {
|
||||
match &err {
|
||||
|
Reference in New Issue
Block a user