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

pub struct HandlerError { /* fields omitted */ }

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

Methods

impl HandlerError
[src]

[src]

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

fn handler(state: State) -> 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
        .into_handler_error()
        .with_status(StatusCode::ImATeapot);

    Box::new(future::err((state, handler_error)))
}

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

Trait Implementations

impl Display for HandlerError
[src]

[src]

Formats the value using the given formatter. Read more

impl Debug for HandlerError
[src]

[src]

Formats the value using the given formatter.

impl Error for HandlerError
[src]

[src]

A short description of the error. Read more

[src]

The lower-level cause of this error, if any. Read more

impl IntoResponse for HandlerError
[src]

[src]

Converts this value into a hyper::Response