Skip to content

Commit

Permalink
fix: improve http client builder error message (denoland#9380)
Browse files Browse the repository at this point in the history
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 denoland#9364.
  • Loading branch information
bnoordhuis committed Feb 3, 2021
1 parent 3f6483e commit fb35838
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion cli/http_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://tools.ietf.org/html/rfc3986#section-4.2>
fn resolve_url_from_location(base_url: &Url, location: &str) -> Url {
Expand Down
3 changes: 2 additions & 1 deletion op_crates/fetch/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)))
}
2 changes: 1 addition & 1 deletion runtime/http_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit fb35838

Please sign in to comment.