diff options
author | ClementTsang <cjhtsang@uwaterloo.ca> | 2020-04-23 14:10:59 -0400 |
---|---|---|
committer | ClementTsang <cjhtsang@uwaterloo.ca> | 2020-04-23 14:10:59 -0400 |
commit | b1f86262f3d4d56772524e4c1830ed89d754d0d6 (patch) | |
tree | 68689662ac6960315b5c187510ca95554111c708 | |
parent | 4d512afdaef0505cd19f1fd895060d8990487db2 (diff) |
refactor: update error messages to be more uniform
-rw-r--r-- | src/app/layout_manager.rs | 4 | ||||
-rw-r--r-- | src/canvas/canvas_colours.rs | 3 | ||||
-rw-r--r-- | src/options.rs | 13 | ||||
-rw-r--r-- | src/utils/error.rs | 10 |
4 files changed, 17 insertions, 13 deletions
diff --git a/src/app/layout_manager.rs b/src/app/layout_manager.rs index 8c6815b0..60a241e2 100644 --- a/src/app/layout_manager.rs +++ b/src/app/layout_manager.rs @@ -929,11 +929,11 @@ impl std::str::FromStr for BottomWidgetType { "net" | "network" => Ok(BottomWidgetType::Net), "proc" | "process" | "processes" => Ok(BottomWidgetType::Proc), "temp" | "temperature" => Ok(BottomWidgetType::Temp), - "disk" => Ok(BottomWidgetType::Disk), + "disk" => Ok(BottomWidgetType::Disk), "empty" => Ok(BottomWidgetType::Empty), "battery" | "batt" => Ok(BottomWidgetType::Battery), _ => Err(BottomError::ConfigError(format!( - "Invalid widget type: {}", + "invalid widget type: {}", s ))), } diff --git a/src/canvas/canvas_colours.rs b/src/canvas/canvas_colours.rs index c38b487d..1e1fe236 100644 --- a/src/canvas/canvas_colours.rs +++ b/src/canvas/canvas_colours.rs @@ -166,7 +166,8 @@ impl CanvasColours { pub fn set_battery_colours(&mut self, colours: &[String]) -> error::Result<()> { if colours.is_empty() { Err(error::BottomError::ConfigError( - "Battery colour list must have at least one colour!".to_string(), + "invalid colour config: battery colour list must have at least one colour!" + .to_string(), )) } else { let generated_colours: Result<Vec<_>, _> = colours diff --git a/src/options.rs b/src/options.rs index f2fa00e3..5b52d17a 100644 --- a/src/options.rs +++ b/src/options.rs @@ -41,7 +41,7 @@ pub struct ConfigFlags { pub default_widget_type: Option<String>, pub default_widget_count: Option<u64>, pub use_old_network_legend: Option<bool>, - pub hide_table_gap : Option<bool>, + pub hide_table_gap: Option<bool>, //disabled_cpu_cores: Option<Vec<u64>>, // TODO: [FEATURE] Enable disabling cores in config/flags } @@ -219,7 +219,11 @@ pub fn build_app( hide_time: get_hide_time(matches, config), autohide_time, use_old_network_legend: get_use_old_network_legend(matches, config), - table_gap: if get_hide_table_gap(matches, config){0}else{1}, + table_gap: if get_hide_table_gap(matches, config) { + 0 + } else { + 1 + }, }; let used_widgets = UsedWidgets { @@ -286,7 +290,7 @@ pub fn get_widget_layout( ret_bottom_layout } else { return Err(error::BottomError::ConfigError( - "Invalid layout - please have at least one widget.".to_string(), + "invalid layout config: please have at least one widget.".to_string(), )); } } else { @@ -342,7 +346,7 @@ fn get_temperature( "kelvin" | "k" => Ok(data_harvester::temperature::TemperatureType::Kelvin), "celsius" | "c" => Ok(data_harvester::temperature::TemperatureType::Celsius), _ => Err(BottomError::ConfigError( - "Invalid temperature type. Please have the value be of the form \ + "invalid temperature type: please have the value be of the form \ <kelvin|k|celsius|c|fahrenheit|f>" .to_string(), )), @@ -633,4 +637,3 @@ pub fn get_hide_table_gap(matches: &clap::ArgMatches<'static>, config: &Config) } false } - diff --git a/src/utils/error.rs b/src/utils/error.rs index e8675f89..41b3d065 100644 --- a/src/utils/error.rs +++ b/src/utils/error.rs @@ -28,24 +28,24 @@ impl std::fmt::Display for BottomError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match *self { BottomError::InvalidIO(ref message) => { - write!(f, "Encountered an IO exception: {}", message) + write!(f, "encountered an IO exception: {}", message) } BottomError::InvalidArg(ref message) => write!(f, "Invalid argument: {}", message), BottomError::InvalidHeim(ref message) => write!( f, - "Invalid error during data collection due to Heim: {}", + "invalid error during data collection due to heim: {}", message ), BottomError::CrosstermError(ref message) => { - write!(f, "Invalid error due to Crossterm: {}", message) + write!(f, "invalid error due to Crossterm: {}", message) } BottomError::GenericError(ref message) => write!(f, "{}", message), BottomError::FernError(ref message) => write!(f, "Invalid fern error: {}", message), BottomError::ConfigError(ref message) => { - write!(f, "Invalid config file error: {}", message) + write!(f, "invalid config file error: {}", message) } BottomError::ConversionError(ref message) => { - write!(f, "Unable to convert: {}", message) + write!(f, "unable to convert: {}", message) } } } |