From 29635b9e3833296b2c908914104ba7165d22d3d5 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Wed, 4 Sep 2024 12:03:13 +0200 Subject: remove `# Panics` and fix clippy --- src/commands/update.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/commands/update.rs') diff --git a/src/commands/update.rs b/src/commands/update.rs index d0b930d..c7965e3 100644 --- a/src/commands/update.rs +++ b/src/commands/update.rs @@ -18,7 +18,6 @@ use crate::{ }; /// # Errors -/// # Panics pub async fn update( config: &Cfg, liststack: Vec, @@ -44,19 +43,26 @@ pub async fn update( update_p.set_message(format!("Update {}", current_list.id)); let list_p = mp.insert_before(&update_p, ProgressBar::new(2)); - list_p - .set_style(ProgressStyle::with_template(STYLE_OPERATION).unwrap()); + list_p.set_style( + ProgressStyle::with_template(STYLE_OPERATION).map_err(|_| { + MLErr::new(EType::LibIndicatif, "template error") + })?, + ); list_p.set_message("Update mods"); let mods = userlist_get_all_ids(config, ¤t_list.id)?; let list_u_p = mp.insert_before( &list_p, - ProgressBar::new(mods.len().try_into().unwrap()), + ProgressBar::new( + mods.len() + .try_into() + .map_err(|_| MLErr::new(EType::Other, "ListStackLen"))?, + ), ); list_u_p.set_style( ProgressStyle::with_template(STYLE_BAR_POS) - .unwrap() + .map_err(|_| MLErr::new(EType::LibIndicatif, "template error"))? .progress_chars(PROGRESS_CHARS), ); @@ -129,12 +135,12 @@ pub async fn update( let d_p = mp.insert_before( &list_p, ProgressBar::new( - current_versions.len().try_into().unwrap(), + current_versions.len().try_into().map_err(|_| MLErr::new(EType::Other, "ListStackLen"))?, ), ); d_p.set_style( ProgressStyle::with_template(STYLE_BAR_POS) - .unwrap() + .map_err(|_| MLErr::new(EType::LibIndicatif, "template error"))? .progress_chars(PROGRESS_CHARS), ); for ver in current_versions { @@ -175,7 +181,7 @@ async fn specific_update( progress: &ProgressBar, ) -> MLE { let applicable_versions = - versions(&config.apis.modrinth, String::from(id), list.clone()).await; + versions(&config.apis.modrinth, String::from(id), list.clone()).await?; let mut versions: Vec = vec![]; -- cgit v1.2.3