tide

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) -> 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) -> Error
where S: TryInto<StatusCode>, <S as TryInto<StatusCode>>::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)

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, Error>
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>(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!

Source

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§

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 Error + '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 Error + Sync + Send + '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<(), Error>

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

impl Display for Error

Source§

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

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

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

Source§

fn from(error: E) -> Error

Converts to this type from the input type.
Source§

impl From<Error> for Box<dyn Error>

Source§

fn from(error: Error) -> Box<dyn Error>

Converts to this type from the input type.
Source§

impl From<Error> for Box<dyn Error + Sync + Send>

Source§

fn from(error: Error) -> Box<dyn Error + Sync + Send>

Converts to this type from the input type.
Source§

impl From<Error> for Response

Source§

fn from(err: 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

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

Source§

impl<T> MaybeSendSync for T