From fb358380c0570103619b0ce71c7fcb1b5a17986c Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 3 Feb 2021 11:40:43 +0100 Subject: [PATCH] fix: improve http client builder error message (#9380) Include the lower-level error message in the generic error message. No test because I can't actually make it fail by passing it bad PEM. I checked and `reqwest::Certificate::from_pem()` always returns `Ok()`. Fixes #9364. --- cli/http_util.rs | 3 ++- op_crates/fetch/lib.rs | 3 ++- runtime/http_util.rs | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cli/http_util.rs b/cli/http_util.rs index 5b6274309a..437b9355c8 100644 --- a/cli/http_util.rs +++ b/cli/http_util.rs @@ -34,8 +34,9 @@ pub fn create_http_client( builder .build() - .map_err(|_| generic_error("Unable to build http client")) + .map_err(|e| generic_error(format!("Unable to build http client: {}", e))) } + /// Construct the next uri based on base uri and location header fragment /// See fn resolve_url_from_location(base_url: &Url, location: &str) -> Url { diff --git a/op_crates/fetch/lib.rs b/op_crates/fetch/lib.rs index 46c72e7a88..23f356a96f 100644 --- a/op_crates/fetch/lib.rs +++ b/op_crates/fetch/lib.rs @@ -3,6 +3,7 @@ #![deny(warnings)] use deno_core::error::bad_resource_id; +use deno_core::error::generic_error; use deno_core::error::type_error; use deno_core::error::AnyError; use deno_core::futures::Future; @@ -433,5 +434,5 @@ fn create_http_client( } builder .build() - .map_err(|_| deno_core::error::generic_error("Unable to build http client")) + .map_err(|e| generic_error(format!("Unable to build http client: {}", e))) } diff --git a/runtime/http_util.rs b/runtime/http_util.rs index 97d6125e0c..72d41d6e35 100644 --- a/runtime/http_util.rs +++ b/runtime/http_util.rs @@ -28,7 +28,7 @@ pub fn create_http_client( builder .build() - .map_err(|_| generic_error("Unable to build http client")) + .map_err(|e| generic_error(format!("Unable to build http client: {}", e))) } #[cfg(test)]