1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-07-01 08:45:10 +02:00

Render error and return as response body

This commit is contained in:
Nikolay Kim
2019-04-03 19:55:19 -07:00
parent 954fe21751
commit 1e2bd68e83
5 changed files with 27 additions and 22 deletions

View File

@ -18,8 +18,6 @@ use tokio_timer::Error as TimerError;
// re-export for convinience
pub use crate::cookie::ParseError as CookieParseError;
use crate::body::Body;
use crate::response::Response;
/// A specialized [`Result`](https://doc.rust-lang.org/std/result/enum.Result.html)
@ -49,13 +47,6 @@ impl Error {
pub fn as_response_error(&self) -> &ResponseError {
self.cause.as_ref()
}
/// Converts error to a response instance and set error message as response body
pub fn response_with_message(self) -> Response {
let message = format!("{}", self);
let resp: Response = self.into();
resp.set_body(Body::from(message))
}
}
/// Error that can be converted to `Response`