Skip to content

An Error that Users can create to give to hyper #1431

Closed
@seanmonstar

Description

@seanmonstar

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 custom Stream. They may need to tell hyper that the stream cannot be completed.
  • 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's Request<B>.
    • The user can provide a Service (and NewService), which returns Future<Item=Response<B>>, where that Future might also fail in creating a Response. 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.

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 just type Error: Into<Box<std::error::Error>>;
  • The Connect trait should update to type Error: Into<Box<std::error::Error>>, and the bounds C::Error: io::Error on client should be removed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-errorArea: error handlingC-featureCategory: feature. This is adding a new feature.E-mediumEffort: medium. Some knowledge of how hyper internal works would be useful.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions