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:
@ -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`
|
||||
|
Reference in New Issue
Block a user