mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-27 17:52:56 +01:00
Response::from_error take impl Into<Error> (#2214)
This commit is contained in:
parent
bb7d33c9d4
commit
3847429d00
@ -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)
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user