pub struct Error { /* private fields */ }
Expand description
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
sourceimpl Error
impl Error
sourcepub fn url(&self) -> Option<&Url>
pub fn url(&self) -> Option<&Url>
Returns a possible URL related to this error.
Examples
// 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);
}
}
}
sourcepub fn url_mut(&mut self) -> Option<&mut Url>
pub fn url_mut(&mut self) -> Option<&mut Url>
Returns a mutable referene 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.
sourcepub fn with_url(self, url: Url) -> Self
pub fn with_url(self, url: Url) -> Self
Add a url related to this error (overwriting any existing)
sourcepub fn without_url(self) -> Self
pub fn without_url(self) -> Self
Strip the related url from this error (if, for example, it contains sensitive information)
sourcepub fn is_builder(&self) -> bool
pub fn is_builder(&self) -> bool
Returns true if the error is from a type Builder.
sourcepub fn is_redirect(&self) -> bool
pub fn is_redirect(&self) -> bool
Returns true if the error is from a RedirectPolicy
.
sourcepub fn is_timeout(&self) -> bool
pub fn is_timeout(&self) -> bool
Returns true if the error is related to a timeout.
sourcepub fn is_request(&self) -> bool
pub fn is_request(&self) -> bool
Returns true if the error is related to the request
sourcepub fn is_connect(&self) -> bool
pub fn is_connect(&self) -> bool
Returns true if the error is related to connect
sourcepub fn is_body(&self) -> bool
pub fn is_body(&self) -> bool
Returns true if the error is related to the request or response body
sourcepub fn is_decode(&self) -> bool
pub fn is_decode(&self) -> bool
Returns true if the error is related to decoding the response’s body
sourcepub fn status(&self) -> Option<StatusCode>
pub fn status(&self) -> Option<StatusCode>
Returns the status code, if the error was generated from a response.
Trait Implementations
sourceimpl Error for Error
impl Error for Error
sourcefn source(&self) -> Option<&(dyn StdError + 'static)>
fn source(&self) -> Option<&(dyn StdError + 'static)>
The lower-level source of this error, if any. Read more
sourcefn backtrace(&self) -> Option<&Backtrace>
fn backtrace(&self) -> Option<&Backtrace>
backtrace
)Returns a stack backtrace, if available, of where this error occurred. Read more
1.0.0 · sourcefn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Auto Trait Implementations
impl !RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl !UnwindSafe for Error
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more