diff --git a/src/types/query.rs b/src/types/query.rs index 46ce26efa..9d4fa4aa1 100644 --- a/src/types/query.rs +++ b/src/types/query.rs @@ -188,8 +188,8 @@ pub struct QueryConfig { impl QueryConfig { /// Set custom error handler pub fn error_handler(mut self, f: F) -> Self - where - F: Fn(QueryPayloadError, &HttpRequest) -> Error + Send + Sync + 'static, + where + F: Fn(QueryPayloadError, &HttpRequest) -> Error + Send + Sync + 'static, { self.ehandler = Some(Arc::new(f)); self @@ -240,12 +240,15 @@ mod tests { #[test] fn test_custom_error_responder() { - let req = TestRequest::with_uri("/name/user1/").data(QueryConfig::default().error_handler(|e, _| { - let resp = HttpResponse::UnprocessableEntity().finish(); - InternalError::from_response(e, resp).into() - })).to_srv_request(); + let req = TestRequest::with_uri("/name/user1/") + .data(QueryConfig::default().error_handler(|e, _| { + let resp = HttpResponse::UnprocessableEntity().finish(); + InternalError::from_response(e, resp).into() + })).to_srv_request(); + let (req, mut pl) = req.into_parts(); let query = Query::::from_request(&req, &mut pl); + assert!(query.is_err()); assert_eq!(query.unwrap_err().as_response_error().error_response().status(), StatusCode::UNPROCESSABLE_ENTITY); }