Enum highnoon::Error

source ·
pub enum Error {
    Http(Response),
    Internal(Error),
}
Expand description

Error type expected to be returned by endpoints.

It can represent an HTTP level error which is useful for helper functions that wish to cause an early return from a handler (using the question mark operator). It can also represent any other kind of error (using the anyhow::Error type). These errors are logged (if you enable the logging filter) and converted to a 500 Internal Server Error with no other details.

HTTP level error should be created with the http methods (which accepts a Responder rather than just Response) and Internal errors should be created with the From/Into implementation.

Variants

Http(Response)

An error that should get returned to the client

Internal(Error)

Internal errors, reported as 500 Internal Server Error and logged locally

Implementations

Create an Error from a Responder - the Responder will be converted to a response and returned to the HTTP Client exactly the same way as an Result::Ok would be. This is useful in conjunction with the ? operator for early returns.

Create a 400 Bad Request Error from a Responder - this method is similar to Error::http but it also sets the status code

Trait Implementations

Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Converts to this type from the input type.

Returns the argument unchanged.

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

Calls U::from(self).

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

Should always be Self
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more