[][src]Struct gotham::handler::HandlerError

pub struct HandlerError { /* fields omitted */ }

Describes an error which occurred during handler execution, and allows the creation of a HTTP Response.


impl HandlerError[src]

pub fn with_status(self, status_code: StatusCode) -> HandlerError[src]

Sets the HTTP status code of the response which is generated by the IntoResponse implementation.

fn handler(state: State) -> Pin<Box<HandlerFuture>> {
    // It's OK if this is bogus, we just need something to convert into a `HandlerError`.
    let io_error = std::io::Error::last_os_error();

    let handler_error = io_error

    future::err((state, handler_error)).boxed()

let test_server = TestServer::new(|| Ok(handler)).unwrap();
let response = test_server.client().get("http://example.com/").perform().unwrap();
assert_eq!(response.status(), StatusCode::IM_A_TEAPOT);

Trait Implementations

impl Debug for HandlerError[src]

impl Display for HandlerError[src]

impl Error for HandlerError[src]

impl IntoResponse for HandlerError[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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

impl<T> Sealed<T> for T where
    T: ?Sized

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.