1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-06-02 21:39:26 +00:00

Response::from_error take impl Into<Error> (#2214)

This commit is contained in:
fakeshadow 2021-05-26 12:41:48 +08:00 committed by GitHub
parent bb7d33c9d4
commit 3847429d00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View file

@ -399,7 +399,7 @@ where
// send service call error as response
Poll::Ready(Err(err)) => {
let res = Response::from_error(err.into());
let res = Response::from_error(err);
let (res, body) = res.replace_body(());
self.as_mut().send_error_response(res, body)?;
}
@ -496,7 +496,7 @@ where
// send expect error as response
Poll::Ready(Err(err)) => {
let res = Response::from_error(err.into());
let res = Response::from_error(err);
let (res, body) = res.replace_body(());
self.as_mut().send_error_response(res, body)?;
}
@ -546,7 +546,7 @@ where
// to notify the dispatcher a new state is set and the outer loop
// should be continue.
Poll::Ready(Err(err)) => {
let res = Response::from_error(err.into());
let res = Response::from_error(err);
let (res, body) = res.replace_body(());
return self.send_error_response(res, body);
}
@ -566,7 +566,7 @@ where
Poll::Pending => Ok(()),
// see the comment on ExpectCall state branch's Ready(Err(err)).
Poll::Ready(Err(err)) => {
let res = Response::from_error(err.into());
let res = Response::from_error(err);
let (res, body) = res.replace_body(());
self.send_error_response(res, body)
}

View file

@ -69,7 +69,8 @@ impl Response<Body> {
/// Constructs a new response from an error.
#[inline]
pub fn from_error(error: Error) -> Response<Body> {
pub fn from_error(error: impl Into<Error>) -> Response<Body> {
let error = error.into();
let resp = error.as_response_error().error_response();
if resp.head.status == StatusCode::INTERNAL_SERVER_ERROR {
debug!("Internal Server Error: {:?}", error);