Closed
Description
Part of the Error reform.
Motivation
Unlike the hyper::Error
, which is meant to describe an error that occurred inside hyper and that information given the user, there a few instances where the user must tell hyper that an error has happened outside, and to stop it's scheduled action.
- In the Client (see also A better Client Error experience #1130):
- The user can create a
Request<B>
, with a customStream
. They may need to tell hyper that the stream cannot be completed.
- The user can create a
- In the Server (see also A better Server Error experience #1128):
- The user can create a
Response<B>
, with the same characterics and needs as the Client'sRequest<B>
. - The user can provide a
Service
(andNewService
), which returnsFuture<Item=Response<B>>
, where thatFuture
might also fail in creating aResponse
. In most cases, a robust server will want to send a response anyways, with a 4XX or 5XX status code, but there could exist instances where the user can't even (or doesn't want to) create those responses.
- The user can create a
While hyper was using tokio-proto, there was a limitation on what error types could be used (only a single error type was allowed), but now that hyper has moved off, we can solve this (even now, before 0.12, I believe).
Design
(updated from #1431 (comment))
Allow E: Into<Box<std::error::Error>>
in any place a user could return an error to hyper. That means:
- In the server,
Service::Error: Into<Box<std::error::Error>>
. - The body streams (
Entity
) a user can provide should be changed to justtype Error: Into<Box<std::error::Error>>;
- The
Connect
trait should update totype Error: Into<Box<std::error::Error>>
, and the boundsC::Error: io::Error
on client should be removed.