diff --git a/src/data_collection/processes/unix/user_table.rs b/src/data_collection/processes/unix/user_table.rs index 1759ad896..ce0c61ffa 100644 --- a/src/data_collection/processes/unix/user_table.rs +++ b/src/data_collection/processes/unix/user_table.rs @@ -1,6 +1,6 @@ use hashbrown::HashMap; -use crate::utils::error; +use crate::utils::error::{self, BottomError}; #[derive(Debug, Default)] pub struct UserTable { @@ -17,13 +17,12 @@ impl UserTable { let passwd = unsafe { libc::getpwuid(uid) }; if passwd.is_null() { - Err(error::BottomError::GenericError( - "passwd is inaccessible".into(), - )) + Err(BottomError::GenericError("passwd is inaccessible".into())) } else { // SAFETY: We return early if passwd is null. let username = unsafe { std::ffi::CStr::from_ptr((*passwd).pw_name) } - .to_str()? + .to_str() + .map_err(|err| BottomError::GenericError(err.to_string()))? .to_string(); self.uid_user_mapping.insert(uid, username.clone()); diff --git a/src/data_collection/temperature/linux.rs b/src/data_collection/temperature/linux.rs index ef920e6da..3f1ac0955 100644 --- a/src/data_collection/temperature/linux.rs +++ b/src/data_collection/temperature/linux.rs @@ -9,7 +9,7 @@ use anyhow::Result; use hashbrown::{HashMap, HashSet}; use super::{is_temp_filtered, TempHarvest, TemperatureType}; -use crate::{app::filter::Filter, utils::error::BottomError}; +use crate::app::filter::Filter; const EMPTY_NAME: &str = "Unknown"; @@ -23,11 +23,7 @@ struct HwmonResults { /// Parses and reads temperatures that were in millidegree Celsius, and if /// successful, returns a temperature in Celsius. fn parse_temp(path: &Path) -> Result { - Ok(fs::read_to_string(path)? - .trim_end() - .parse::() - .map_err(|e| BottomError::ConversionError(e.to_string()))? - / 1_000.0) + Ok(fs::read_to_string(path)?.trim_end().parse::()? / 1_000.0) } /// Get all candidates from hwmon and coretemp. It will also return the number diff --git a/src/utils/error.rs b/src/utils/error.rs index 6a584e286..da9fb5660 100644 --- a/src/utils/error.rs +++ b/src/utils/error.rs @@ -11,9 +11,6 @@ pub enum BottomError { /// An error when there is an IO exception. #[error("IO exception, {0}")] InvalidIo(String), - /// An error when the Crossterm library encounters a problem. - #[error("Error caused by Crossterm, {0}")] - CrosstermError(String), /// An error to represent generic errors. #[error("Error, {0}")] GenericError(String), @@ -23,9 +20,6 @@ pub enum BottomError { /// An error to represent errors with the config. #[error("Configuration file error, {0}")] ConfigError(String), - /// An error to represent errors with converting between data types. - #[error("Conversion error, {0}")] - ConversionError(String), } impl From for BottomError { @@ -51,15 +45,3 @@ impl From for BottomError { BottomError::ConfigError(err.to_string()) } } - -impl From for BottomError { - fn from(err: std::str::Utf8Error) -> Self { - BottomError::ConversionError(err.to_string()) - } -} - -impl From for BottomError { - fn from(err: std::string::FromUtf8Error) -> Self { - BottomError::ConversionError(err.to_string()) - } -}