mirror of
https://github.com/ClementTsang/bottom
synced 2024-11-26 22:20:18 +00:00
refactor: update error messages to be more uniform
This commit is contained in:
parent
4d512afdae
commit
b1f86262f3
4 changed files with 17 additions and 13 deletions
|
@ -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
|
||||
))),
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue