mirror of
https://github.com/fafhrd91/actix-web
synced 2025-06-25 06:39:22 +02:00
remove error field from response
This commit is contained in:
@ -20,7 +20,6 @@ use crate::{
|
||||
pub struct Response<B> {
|
||||
pub(crate) head: BoxedResponseHead,
|
||||
pub(crate) body: B,
|
||||
pub(crate) error: Option<Error>,
|
||||
}
|
||||
|
||||
impl Response<Body> {
|
||||
@ -30,7 +29,6 @@ impl Response<Body> {
|
||||
Response {
|
||||
head: BoxedResponseHead::new(status),
|
||||
body: Body::Empty,
|
||||
error: None,
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,11 +70,10 @@ impl Response<Body> {
|
||||
/// Constructs a new response from an error.
|
||||
#[inline]
|
||||
pub fn from_error(error: Error) -> Response<Body> {
|
||||
let mut resp = error.as_response_error().error_response();
|
||||
let resp = error.as_response_error().error_response();
|
||||
if resp.head.status == StatusCode::INTERNAL_SERVER_ERROR {
|
||||
debug!("Internal Server Error: {:?}", error);
|
||||
}
|
||||
resp.error = Some(error);
|
||||
resp
|
||||
}
|
||||
}
|
||||
@ -88,7 +85,6 @@ impl<B> Response<B> {
|
||||
Response {
|
||||
head: BoxedResponseHead::new(status),
|
||||
body: body,
|
||||
error: None,
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,12 +100,6 @@ impl<B> Response<B> {
|
||||
&mut *self.head
|
||||
}
|
||||
|
||||
/// Returns the source `error` for this response, if one is set.
|
||||
#[inline]
|
||||
pub fn error(&self) -> Option<&Error> {
|
||||
self.error.as_ref()
|
||||
}
|
||||
|
||||
/// Returns the status code of this response.
|
||||
#[inline]
|
||||
pub fn status(&self) -> StatusCode {
|
||||
@ -168,7 +158,6 @@ impl<B> Response<B> {
|
||||
Response {
|
||||
head: self.head,
|
||||
body,
|
||||
error: None,
|
||||
}
|
||||
}
|
||||
|
||||
@ -183,7 +172,6 @@ impl<B> Response<B> {
|
||||
Response {
|
||||
head: self.head,
|
||||
body,
|
||||
error: self.error,
|
||||
},
|
||||
self.body,
|
||||
)
|
||||
@ -208,7 +196,6 @@ impl<B> Response<B> {
|
||||
Response {
|
||||
head: self.head,
|
||||
body,
|
||||
error: self.error,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -248,13 +248,8 @@ impl ResponseBuilder {
|
||||
return Err(err.into());
|
||||
}
|
||||
|
||||
let response = self.head.take().expect("cannot reuse response builder");
|
||||
|
||||
Ok(Response {
|
||||
head: response,
|
||||
body,
|
||||
error: None,
|
||||
})
|
||||
let head = self.head.take().expect("cannot reuse response builder");
|
||||
Ok(Response { head, body })
|
||||
}
|
||||
|
||||
/// Generate response with a streaming body.
|
||||
|
Reference in New Issue
Block a user