From 4292bbeea01bcdb8224abee0a6ba3272911225bd Mon Sep 17 00:00:00 2001 From: Noah Sherwin Date: Fri, 17 Apr 2026 17:08:31 -0700 Subject: [PATCH 1/2] fix(core.api.client): print fetch_all_mods errors after it completes Because this solution wraps a Result with another Result, it increases complexity a bit, but this is more acceptable than alternatives such as... - Change the return type of `ApiClient.fetch_mod` to accommodate a String-type alternative result. `fetch_mod` would never use this alternative return type; only callers would use it. This breaking change had insufficient justification. - Store error messages in a `Mutex>`. Each task would use `i` to index into their own, exclusive entries in the vector. However, the compiler was not satisfied by the way I wanted to do it. I could have added a thread-safe Vector dependency or implemented a message queue, but both were big changes for what seemed like a small problem. Fixes #54 "Errors in `fetch_all_mods` interrupt the progress bar" --- rustique-core/src/api/client.rs | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/rustique-core/src/api/client.rs b/rustique-core/src/api/client.rs index 16f6c28..77c5d98 100755 --- a/rustique-core/src/api/client.rs +++ b/rustique-core/src/api/client.rs @@ -169,8 +169,7 @@ impl ApiClient { pb.set_message("Fetching mods..."); // Create a vector to hold all our task handles - let mut tasks: Vec>> = Vec::with_capacity(valid_ids.len()); - + let mut tasks: Vec>> = Vec::with_capacity(valid_ids.len()); // Spawn a task for each mod for (i, mod_id) in valid_ids.into_iter().enumerate() { info!("ModID: {}", mod_id); @@ -183,13 +182,15 @@ impl ApiClient { Ok(the_mod) => { pb_clone.set_message(mod_id.to_string()); pb_clone.inc(1); - Some((mod_id, the_mod)) + Ok((mod_id, the_mod)) }, Err(e) => { - error!("{mod_id} {e}"); - pb_clone.set_message(format!("Failed: {}", mod_id.red())); pb_clone.inc(1); - None + Err(format!( + "Failed: {0}\nError:\n{1}\n", + &mod_id.red(), + &e.to_string().red() + )) } } }); @@ -205,12 +206,23 @@ impl ApiClient { let results_vec = join_all(tasks).await; // Wait for all tasks to complete and collect results let mut results = HashMap::new(); - for (mod_id, mod_info) in results_vec.into_iter().flatten().flatten() { - // Handle any JoinError from the task itself - results.insert(mod_id, mod_info); + let mut error_messages: Vec = Vec::with_capacity(results_vec.len()); + for result in results_vec.into_iter().flatten() { + match result { + Ok((mod_id, mod_info)) => { + // Handle any JoinError from the task itself + results.insert(mod_id, mod_info); + } + Err(error_message) => { + error_messages.push(error_message); + } + } } pb.finish_with_message("Fetch Complete"); + for err in error_messages.iter() { + error!(err) + } Ok(results) } From b284cfaf079412ac2efe168eaf67d9a8dd5d50ea Mon Sep 17 00:00:00 2001 From: Noah Sherwin Date: Sat, 2 May 2026 13:57:28 -0700 Subject: [PATCH 2/2] refactor(core.api.client): print errors w/ different `error!` arm This fixes the unexpectedly re-formatted error messages issue introduced in 4292bbe --- rustique-core/src/api/client.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rustique-core/src/api/client.rs b/rustique-core/src/api/client.rs index 77c5d98..077dd4c 100755 --- a/rustique-core/src/api/client.rs +++ b/rustique-core/src/api/client.rs @@ -221,7 +221,7 @@ impl ApiClient { pb.finish_with_message("Fetch Complete"); for err in error_messages.iter() { - error!(err) + error!("{}", err); } Ok(results) }