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
sourceimpl 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
sourceimpl Debug for HandlerError
impl Debug for HandlerError
sourceimpl Display for HandlerError
impl Display for HandlerError
sourceimpl Error for HandlerError
impl Error for HandlerError
sourcefn description(&self) -> &str
fn description(&self) -> &str
👎 Deprecated since 1.42.0:
use the Display impl or to_string()
sourcefn cause(&self) -> Option<&dyn Error>
fn cause(&self) -> Option<&dyn Error>
👎 Deprecated since 1.33.0:
replaced by Error::source, which can support downcasting
sourceimpl IntoResponse for HandlerError
impl IntoResponse for HandlerError
sourcefn into_response(self, state: &State) -> Response<Body>
fn into_response(self, state: &State) -> Response<Body>
Converts this value into a hyper::Response
Auto Trait Implementations
impl !RefUnwindSafe for HandlerError
impl Send for HandlerError
impl !Sync for HandlerError
impl Unpin for HandlerError
impl !UnwindSafe for HandlerError
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more