Struct gotham::handler::HandlerError
source · pub struct HandlerError { /* private fields */ }
Expand description
Describes an error which occurred during handler execution, and allows the creation of a HTTP
Response
.
Implementations§
source§impl HandlerError
impl HandlerError
sourcepub fn with_status(self, status_code: StatusCode) -> HandlerError
pub fn with_status(self, status_code: StatusCode) -> HandlerError
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::IM_A_TEAPOT);
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::IM_A_TEAPOT);
Trait Implementations§
source§impl Debug for HandlerError
impl Debug for HandlerError
source§impl Display for HandlerError
impl Display for HandlerError
source§impl Error for HandlerError
impl Error for HandlerError
source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
source§fn cause(&self) -> Option<&dyn Error>
fn cause(&self) -> Option<&dyn Error>
👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting