Rename error name.
This commit is contained in:
parent
12b4518fa1
commit
8d5db7aa79
|
@ -11,13 +11,13 @@ pub mod network;
|
|||
pub mod processes;
|
||||
pub mod temperature;
|
||||
|
||||
fn set_if_valid<T: std::clone::Clone>(result: &Result<T, crate::utils::error::RustopError>, value_to_set: &mut T) {
|
||||
fn set_if_valid<T: std::clone::Clone>(result: &Result<T, crate::utils::error::BottomError>, value_to_set: &mut T) {
|
||||
if let Ok(result) = result {
|
||||
*value_to_set = (*result).clone();
|
||||
}
|
||||
}
|
||||
|
||||
fn push_if_valid<T: std::clone::Clone>(result: &Result<T, crate::utils::error::RustopError>, vector_to_push: &mut Vec<T>) {
|
||||
fn push_if_valid<T: std::clone::Clone>(result: &Result<T, crate::utils::error::BottomError>, vector_to_push: &mut Vec<T>) {
|
||||
if let Ok(result) = result {
|
||||
vector_to_push.push(result.clone());
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ mod data_conversion;
|
|||
use app::data_collection;
|
||||
use constants::TICK_RATE_IN_MILLISECONDS;
|
||||
use data_conversion::*;
|
||||
use utils::error::{self, RustopError};
|
||||
use utils::error::{self, BottomError};
|
||||
|
||||
// End imports
|
||||
|
||||
|
@ -74,11 +74,11 @@ fn main() -> error::Result<()> {
|
|||
};
|
||||
|
||||
if update_rate_in_milliseconds < 250 {
|
||||
return Err(RustopError::InvalidArg {
|
||||
return Err(BottomError::InvalidArg {
|
||||
message: "Please set your update rate to be greater than 250 milliseconds.".to_string(),
|
||||
});
|
||||
} else if update_rate_in_milliseconds > u128::from(std::u64::MAX) {
|
||||
return Err(RustopError::InvalidArg {
|
||||
return Err(BottomError::InvalidArg {
|
||||
message: "Please set your update rate to be less than unsigned INT_MAX.".to_string(),
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use failure::Fail;
|
||||
use std::result;
|
||||
|
||||
/// A type alias for handling errors related to Rustop.
|
||||
pub type Result<T> = result::Result<T, RustopError>;
|
||||
/// A type alias for handling errors related to Bottom.
|
||||
pub type Result<T> = result::Result<T, BottomError>;
|
||||
|
||||
/// An error that can occur while Rustop runs.
|
||||
/// An error that can occur while Bottom runs.
|
||||
#[derive(Debug, Fail)]
|
||||
pub enum RustopError {
|
||||
pub enum BottomError {
|
||||
/// An error when there is an IO exception.
|
||||
///
|
||||
/// The data provided is the error found.
|
||||
|
@ -39,38 +39,38 @@ pub enum RustopError {
|
|||
FernError { message: String },
|
||||
}
|
||||
|
||||
impl From<std::io::Error> for RustopError {
|
||||
impl From<std::io::Error> for BottomError {
|
||||
fn from(err: std::io::Error) -> Self {
|
||||
RustopError::InvalidIO { message: err.to_string() }
|
||||
BottomError::InvalidIO { message: err.to_string() }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<heim::Error> for RustopError {
|
||||
impl From<heim::Error> for BottomError {
|
||||
fn from(err: heim::Error) -> Self {
|
||||
RustopError::InvalidHeim { message: err.to_string() }
|
||||
BottomError::InvalidHeim { message: err.to_string() }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<crossterm::ErrorKind> for RustopError {
|
||||
impl From<crossterm::ErrorKind> for BottomError {
|
||||
fn from(err: crossterm::ErrorKind) -> Self {
|
||||
RustopError::CrosstermError { message: err.to_string() }
|
||||
BottomError::CrosstermError { message: err.to_string() }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::num::ParseIntError> for RustopError {
|
||||
impl From<std::num::ParseIntError> for BottomError {
|
||||
fn from(err: std::num::ParseIntError) -> Self {
|
||||
RustopError::InvalidArg { message: err.to_string() }
|
||||
BottomError::InvalidArg { message: err.to_string() }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::string::String> for RustopError {
|
||||
impl From<std::string::String> for BottomError {
|
||||
fn from(err: std::string::String) -> Self {
|
||||
RustopError::GenericError { message: err.to_string() }
|
||||
BottomError::GenericError { message: err.to_string() }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<fern::InitError> for RustopError {
|
||||
impl From<fern::InitError> for BottomError {
|
||||
fn from(err: fern::InitError) -> Self {
|
||||
RustopError::FernError { message: err.to_string() }
|
||||
BottomError::FernError { message: err.to_string() }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue