fix: don't quit at first fill() failure

This commit is contained in:
əlemi 2024-10-25 17:30:30 +02:00
parent b3fe8faaba
commit 5670b8b67a

View file

@ -149,7 +149,10 @@ async fn run_collection_endpoints(
// this is always safe to compile because we tested it beforehand // this is always safe to compile because we tested it beforehand
let pattern = regex::Regex::new(&query).expect("tested it before and still failed here???"); let pattern = regex::Regex::new(&query).expect("tested it before and still failed here???");
let env = std::sync::Arc::new(collection.env); let env = std::sync::Arc::new(collection.env);
let client = std::sync::Arc::new(collection.client.fill(&env)); let client = match collection.client.fill(&env) {
Ok(c) => std::sync::Arc::new(c),
Err(e) => return eprintln!("[!]error preparing client for '{namespace}': {e}"),
};
for (name, mut endpoint) in collection.route { for (name, mut endpoint) in collection.route {
let full_name = ext::full_name(&namespace, &name); let full_name = ext::full_name(&namespace, &name);
@ -164,13 +167,13 @@ async fn run_collection_endpoints(
let before = chrono::Local::now(); let before = chrono::Local::now();
eprintln!(" : [{}] {full_name} \tsending request...", before.format(fmt::TIMESTAMP_FMT)); eprintln!(" : [{}] {full_name} \tsending request...", before.format(fmt::TIMESTAMP_FMT));
let res = if dry_run { let res = match endpoint.fill(&_env) {
Ok(e) => if dry_run {
Ok("".to_string()) Ok("".to_string())
} else { } else {
endpoint e.execute(&_client).await
.fill(&_env) },
.execute(&_client) Err(e) => Err(e.into()),
.await
}; };
let after = chrono::Local::now(); let after = chrono::Local::now();
@ -179,7 +182,7 @@ async fn run_collection_endpoints(
let timestamp = after.format(fmt::TIMESTAMP_FMT); let timestamp = after.format(fmt::TIMESTAMP_FMT);
let symbol = if res.is_ok() { " + " } else { "<!>" }; let symbol = if res.is_ok() { " + " } else { "<!>" };
let verb = if res.is_ok() { "done in" } else { "failed after" }; let verb = if res.is_ok() { "done in" } else { "failed after" };
eprintln!("{symbol}[{timestamp}] {_namespace}::{name} \t{verb} {elapsed}ms", ); eprintln!("{symbol}[{timestamp}] {_namespace}:{name} \t{verb} {elapsed}ms", );
if report { if report {
(res, _namespace, name, elapsed).report(); (res, _namespace, name, elapsed).report();