diff --git a/crates/autopilot/src/infra/solvers/mod.rs b/crates/autopilot/src/infra/solvers/mod.rs index 67c1062451..0c35d42f92 100644 --- a/crates/autopilot/src/infra/solvers/mod.rs +++ b/crates/autopilot/src/infra/solvers/mod.rs @@ -28,10 +28,12 @@ pub struct Driver { pub enum Error { #[error("unable to load KMS account")] UnableToLoadKmsAccount, + #[error("failed to build client")] + FailedToBuildClient(#[source] reqwest::Error), } impl Driver { - pub async fn new( + pub async fn try_new( url: Url, name: String, fairness_threshold: Option, @@ -59,7 +61,7 @@ impl Driver { client: Client::builder() .timeout(RESPONSE_TIME_LIMIT) .build() - .unwrap(), + .map_err(Error::FailedToBuildClient)?, submission_address: submission_address.into(), }) } diff --git a/crates/autopilot/src/run.rs b/crates/autopilot/src/run.rs index fd3407d446..1ea1f6de93 100644 --- a/crates/autopilot/src/run.rs +++ b/crates/autopilot/src/run.rs @@ -552,22 +552,21 @@ pub async fn run(args: Arguments) { .drivers .into_iter() .map(|driver| async move { - infra::Driver::new( + infra::Driver::try_new( driver.url, driver.name.clone(), driver.fairness_threshold.map(Into::into), driver.submission_account, ) .await - .ok() .map(Arc::new) + .expect("failed to load solver configuration") }) .collect::>(); let drivers = futures::future::join_all(drivers_futures) .await .into_iter() - .flatten() .collect(); let run = RunLoop::new( @@ -595,22 +594,21 @@ async fn shadow_mode(args: Arguments) -> ! { .drivers .into_iter() .map(|driver| async move { - infra::Driver::new( + infra::Driver::try_new( driver.url, driver.name.clone(), driver.fairness_threshold.map(Into::into), driver.submission_account, ) .await - .ok() .map(Arc::new) + .expect("failed to load solver configuration") }) .collect::>(); let drivers = futures::future::join_all(drivers_futures) .await .into_iter() - .flatten() .collect(); let trusted_tokens = {