Struct Error
pub struct Error { /* private fields */ }
The Errors that may occur when processing a Request.
Note: Errors may include the full URL used to make the Request. If the URL
contains sensitive information (e.g. an API key as a query parameter), be
sure to remove it (without_url)
Implementations
impl Error
fn url(&self) -> Option<&Url>Returns a possible URL related to this error.
Examples
# async fn run() { // displays last stop of a redirect loop let response = reqwest::get("http://site.with.redirect.loop").await; if let Err(e) = response { if e.is_redirect() { if let Some(final_stop) = e.url() { println!("redirect loop at {final_stop}"); } } } # }fn url_mut(&mut self) -> Option<&mut Url>Returns a mutable reference to the URL related to this error
This is useful if you need to remove sensitive information from the URL (e.g. an API key in the query), but do not want to remove the URL entirely.
fn with_url(self, url: Url) -> SelfAdd a url related to this error (overwriting any existing)
fn without_url(self) -> SelfStrip the related url from this error (if, for example, it contains sensitive information)
fn is_builder(&self) -> boolReturns true if the error is from a type Builder.
fn is_redirect(&self) -> boolReturns true if the error is from a
RedirectPolicy.fn is_status(&self) -> boolReturns true if the error is from
Response::error_for_status.fn is_timeout(&self) -> boolReturns true if the error is related to a timeout.
fn is_request(&self) -> boolReturns true if the error is related to the request
fn is_connect(&self) -> boolReturns true if the error is related to connect
fn is_dns(&self) -> boolReturns true if the error is related to DNS resolution.
fn is_body(&self) -> boolReturns true if the error is related to the request or response body
fn is_decode(&self) -> boolReturns true if the error is related to decoding the response's body
fn status(&self) -> Option<StatusCode>Returns the status code, if the error was generated from a response.
fn is_upgrade(&self) -> boolReturns true if the error is related to a protocol upgrade request
Trait Implementations
impl Debug for Error
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Display for Error
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Error for Error
fn source(&self) -> Option<&dyn StdError + 'static>