Struct ajars_surf::surf::http::Error
[−]pub struct Error { /* private fields */ }
Expand description
The error type for HTTP operations.
Implementations
impl Error
impl Error
pub fn new<S, E>(status: S, error: E) -> Error where
S: TryInto<StatusCode>,
E: Into<Error>,
<S as TryInto<StatusCode>>::Error: Debug,
pub fn new<S, E>(status: S, error: E) -> Error where
S: TryInto<StatusCode>,
E: Into<Error>,
<S as TryInto<StatusCode>>::Error: Debug,
Create a new error object from any error type.
The error type must be threadsafe and ’static, so that the Error will be as well. If the error type does not provide a backtrace, a backtrace will be created here to ensure that a backtrace exists.
pub fn from_str<S, M>(status: S, msg: M) -> Error where
S: TryInto<StatusCode>,
M: 'static + Display + Debug + Send + Sync,
<S as TryInto<StatusCode>>::Error: Debug,
pub fn from_str<S, M>(status: S, msg: M) -> Error where
S: TryInto<StatusCode>,
M: 'static + Display + Debug + Send + Sync,
<S as TryInto<StatusCode>>::Error: Debug,
Create a new error object from static string.
pub fn status(&self) -> StatusCode
pub fn status(&self) -> StatusCode
Get the status code associated with this error.
pub fn set_status<S>(&mut self, status: S) where
S: TryInto<StatusCode>,
<S as TryInto<StatusCode>>::Error: Debug,
pub fn set_status<S>(&mut self, status: S) where
S: TryInto<StatusCode>,
<S as TryInto<StatusCode>>::Error: Debug,
Set the status code associated with this error.
pub fn backtrace(&self) -> Option<&Backtrace>
pub fn backtrace(&self) -> Option<&Backtrace>
Get the backtrace for this Error.
Backtraces are only available on the nightly channel. Tracking issue: rust-lang/rust#53487.
In order for the backtrace to be meaningful, the environment variable
RUST_LIB_BACKTRACE=1
must be defined. Backtraces are somewhat
expensive to capture in Rust, so we don’t necessarily want to be
capturing them all over the place all the time.
Note: This function can be called whether or not backtraces
are enabled and available. It will return a None
variant if
compiled on a toolchain that does not support backtraces, or
if executed without backtraces enabled with
RUST_LIB_BACKTRACE=1
.
pub fn into_inner(self) -> Error
pub fn into_inner(self) -> Error
Returns the inner [anyhow::Error
]
Note: This will lose status code information
pub fn downcast<E>(self) -> Result<E, Error> where
E: 'static + Display + Debug + Send + Sync,
pub fn downcast<E>(self) -> Result<E, Error> where
E: 'static + Display + Debug + Send + Sync,
Attempt to downcast the error object to a concrete type.
pub fn downcast_ref<E>(&self) -> Option<&E> where
E: 'static + Display + Debug + Send + Sync,
pub fn downcast_ref<E>(&self) -> Option<&E> where
E: 'static + Display + Debug + Send + Sync,
Downcast this error object by reference.
pub fn downcast_mut<E>(&mut self) -> Option<&mut E> where
E: 'static + Display + Debug + Send + Sync,
pub fn downcast_mut<E>(&mut self) -> Option<&mut E> where
E: 'static + Display + Debug + Send + Sync,
Downcast this error object by mutable reference.
pub fn type_name(&self) -> Option<&str>
pub fn type_name(&self) -> Option<&str>
Retrieves a reference to the type name of the error, if available.
pub fn from_display<D>(error: D) -> Error where
D: Display,
pub fn from_display<D>(error: D) -> Error where
D: Display,
Converts anything which implements Display
into an http_types::Error
.
This is handy for errors which are not Send + Sync + 'static
because std::error::Error
requires Display
.
Note that any assiciated context not included in the Display
output will be lost,
and so this may be lossy for some types which implement std::error::Error
.
Note: Prefer error.into()
via From<Into<anyhow::Error>>
when possible!
pub fn from_debug<D>(error: D) -> Error where
D: Debug,
pub fn from_debug<D>(error: D) -> Error where
D: Debug,
Converts anything which implements Debug
into an http_types::Error
.
This is handy for errors which are not Send + Sync + 'static
because std::error::Error
requires Debug
.
Note that any assiciated context not included in the Debug
output will be lost,
and so this may be lossy for some types which implement std::error::Error
.
Note: Prefer error.into()
via From<Into<anyhow::Error>>
when possible!
Trait Implementations
impl AsMut<StatusCode> for Error
impl AsMut<StatusCode> for Error
fn as_mut(&mut self) -> &mut StatusCode
fn as_mut(&mut self) -> &mut StatusCode
Converts this type into a mutable reference of the (usually inferred) input type.
impl AsRef<StatusCode> for Error
impl AsRef<StatusCode> for Error
fn as_ref(&self) -> &StatusCode
fn as_ref(&self) -> &StatusCode
Converts this type into a shared reference of the (usually inferred) input type.
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 · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more