Trait gotham::handler::MapHandlerError [−][src]
This trait allows you to convert a Result
’s Err
case into a handler error with the given
status code. This is handy if you want to specify the status code but still use the ?
shorthand.
fn handler() -> Result<(), HandlerError> { let result = Err(anyhow!("just a test")); result.map_err_with_status(StatusCode::IM_A_TEAPOT)?; unreachable!() } let response = handler(); assert_eq!(response.map_err(|err| err.status()), Err(StatusCode::IM_A_TEAPOT));
Required methods
fn map_err_with_status(self, status_code: StatusCode) -> Result<T, HandlerError>
[src]
Equivalent of map_err(|err| HandlerError::from(err).with_status(status_code))
.
Implementations on Foreign Types
impl<T, E> MapHandlerError<T> for Result<T, E> where
E: Into<Error> + Display,
[src]
E: Into<Error> + Display,