diff --git a/src/errors.rs b/src/errors.rs index 3bac8357..13c47469 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -62,11 +62,11 @@ pub enum Error { HttpError(reqwest::Error), #[error("Invalid URL: {}", .0)] - InvalidUrl(url::ParseError), + InvalidUrl(#[from] url::ParseError), /// The http client encountered an error. #[error("Invalid HTTP header: {}", .0)] - InvalidHttpHeaderValue(http::header::InvalidHeaderValue), + InvalidHttpHeaderValue(#[from] http::header::InvalidHeaderValue), /// The http client encountered an error. #[cfg(target_arch = "wasm32")] @@ -293,12 +293,6 @@ impl std::fmt::Display for ErrorCode { } } -impl From for Error { - fn from(error: http::header::InvalidHeaderValue) -> Error { - Error::InvalidHttpHeaderValue(error) - } -} - #[cfg(all( not(target_arch = "wasm32"), any(feature = "isahc-static-curl", feature = "isahc-static-ssl") diff --git a/src/request.rs b/src/request.rs index 1e60db50..c8d126e1 100644 --- a/src/request.rs +++ b/src/request.rs @@ -147,13 +147,9 @@ trait RequestClient<'a, B: 'a>: Sized { Q: Serialize + 'a, T: DeserializeOwned, { - let mut request_client = Self::new( - add_query_parameters(url, method.query())? - .parse() - .map_err(Error::InvalidUrl)?, - ) - .with_method(method.http_method()) - .append_header(header::USER_AGENT, USER_AGENT_HEADER_VALUE.clone()); + let mut request_client = Self::new(add_query_parameters(url, method.query())?.parse()?) + .with_method(method.http_method()) + .append_header(header::USER_AGENT, USER_AGENT_HEADER_VALUE.clone()); if let Some(apikey) = apikey { request_client = request_client