mirror of
https://github.com/actix/actix-web.git
synced 2024-11-26 19:41:12 +00:00
allow to create response with error message
This commit is contained in:
parent
c2540cc59b
commit
148cf73003
1 changed files with 8 additions and 0 deletions
|
@ -98,6 +98,14 @@ impl Error {
|
|||
Fail::downcast_ref(self.cause.as_fail());
|
||||
compat.and_then(|e| e.get_ref().downcast_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 mut resp: Response = self.into();
|
||||
resp.set_body(message);
|
||||
resp
|
||||
}
|
||||
}
|
||||
|
||||
/// Helper trait to downcast a response error into a fail.
|
||||
|
|
Loading…
Reference in a new issue