Deprecate 'Result<T, E>, E: !Responder' responder.

This commit is contained in:
Sergio Benitez 2019-09-09 17:23:11 -07:00
parent ff535c2ff9
commit 436a5aad57
1 changed files with 7 additions and 0 deletions

View File

@ -271,10 +271,17 @@ impl<'r, R: Responder<'r>> Responder<'r> for Option<R> {
/// If `self` is `Ok`, responds with the wrapped `Responder`. Otherwise prints /// If `self` is `Ok`, responds with the wrapped `Responder`. Otherwise prints
/// an error message with the `Err` value returns an `Err` of /// an error message with the `Err` value returns an `Err` of
/// `Status::InternalServerError`. /// `Status::InternalServerError`.
#[deprecated(since = "0.4.3")]
impl<'r, R: Responder<'r>, E: fmt::Debug> Responder<'r> for Result<R, E> { impl<'r, R: Responder<'r>, E: fmt::Debug> Responder<'r> for Result<R, E> {
default fn respond_to(self, req: &Request) -> response::Result<'r> { default fn respond_to(self, req: &Request) -> response::Result<'r> {
self.map(|r| r.respond_to(req)).unwrap_or_else(|e| { self.map(|r| r.respond_to(req)).unwrap_or_else(|e| {
error_!("Response was a non-`Responder` `Err`: {:?}.", e); error_!("Response was a non-`Responder` `Err`: {:?}.", e);
warn_!("This `Responder` implementation has been deprecated.");
warn_!(
"In Rocket v0.5, `Result<T, E>` implements `Responder` only if \
`E` implements `Responder`. For the previous behavior, use \
`Result<T, Debug<E>>` where `Debug` is `rocket::response::Debug`."
);
Err(Status::InternalServerError) Err(Status::InternalServerError)
}) })
} }