http_types

Struct Error

source
pub struct Error { /* private fields */ }
Expand description

The error type for HTTP operations.

Implementations§

source§

impl Error

source

pub fn new<S, E>(status: S, error: E) -> Self
where S: TryInto<StatusCode>, S::Error: Debug, E: Into<Error>,

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.

source

pub fn from_str<S, M>(status: S, msg: M) -> Self
where S: TryInto<StatusCode>, S::Error: Debug, M: Display + Debug + Send + Sync + 'static,

Create a new error object from static string.

source

pub fn status(&self) -> StatusCode

Get the status code associated with this error.

source

pub fn set_status<S>(&mut self, status: S)
where S: TryInto<StatusCode>, S::Error: Debug,

Set the status code associated with this error.

source

pub const fn backtrace(&self) -> Option<BacktracePlaceholder>

source

pub fn into_inner(self) -> Error

Returns the inner anyhow::Error Note: This will lose status code information

source

pub fn downcast<E>(self) -> Result<E, Self>
where E: Display + Debug + Send + Sync + 'static,

Attempt to downcast the error object to a concrete type.

source

pub fn downcast_ref<E>(&self) -> Option<&E>
where E: Display + Debug + Send + Sync + 'static,

Downcast this error object by reference.

source

pub fn downcast_mut<E>(&mut self) -> Option<&mut E>
where E: Display + Debug + Send + Sync + 'static,

Downcast this error object by mutable reference.

source

pub fn type_name(&self) -> Option<&str>

Retrieves a reference to the type name of the error, if available.

source

pub fn from_display<D: Display>(error: D) -> Self

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!

source

pub fn from_debug<D: Debug>(error: D) -> Self

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§

source§

impl AsMut<StatusCode> for Error

source§

fn as_mut(&mut self) -> &mut StatusCode

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl AsRef<Error> for Error

source§

fn as_ref(&self) -> &Error

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl AsRef<StatusCode> for Error

source§

fn as_ref(&self) -> &StatusCode

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl AsRef<dyn Error> for Error

source§

fn as_ref(&self) -> &(dyn StdError + 'static)

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl AsRef<dyn Error + Sync + Send> for Error

source§

fn as_ref(&self) -> &(dyn StdError + Send + Sync + 'static)

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Debug for Error

source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for Error

source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<E: Into<Error>> From<E> for Error

source§

fn from(error: E) -> Self

Converts to this type from the input type.
source§

impl From<Error> for Box<dyn StdError + 'static>

source§

fn from(error: Error) -> Self

Converts to this type from the input type.
source§

impl From<Error> for Box<dyn StdError + Send + Sync + 'static>

source§

fn from(error: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Error

§

impl RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnwindSafe for Error

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<!> for T

source§

fn from(t: !) -> T

Converts to this type from the input type.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T