Skip to content

Error type redesign #1131

Open
Open
@seanmonstar

Description

@seanmonstar

The Error type in hyper is currently an enum, wrapping up the various cases of things that could go wrong when parsing incoming HTTP data. Some of the problems with the current design:

  • Being an enum means that adding variants is a breaking change. There is a __Nonexhaustive variant to try to warn that exhaustive matches can cause breaking changes, but that it's better when internals are hidden.
  • Users sometimes try to create hyper::Errors, even though they really shouldn't. It is meant only for saying "this thing went wrong while hyper was parsing HTTP", and nothing else. Part of this can be fixed also by changing the actual error types used, such as in outgoing Streams.

Instead, I'd like to propose making the Error an opaque struct, with some methods to inspect the type and details of an error, somewhat along the lines of std::io::Error.

(Still thinking through the specific code, will add a design section later).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-errorArea: error handlingB-rfcBlocked: More comments would be useful in determine next steps.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions