Skip to content

Create a hyper::error::Code type #2845

@seanmonstar

Description

@seanmonstar

Create a new opaque struct Code in hyper::error, that contains constants of errors that could happen in hyper.

pub struct Code(Code_);

enum Code_ {
    Canceled,
    // etc
}

impl Code {
    pub const CANCELED: Code = Code(Code_::Canceled);
}

Should it be an opaque struct, or a non-exhaustive enum?

Proposal welcome

A motivated individual that would like to be able to inspect errors, and send HTTP 2/3 errors, can take this on and propose how exactly to add this. Note the following for whatever would be accepted:

  • Conservative: we can add things, but we can't take anything away. Err on minimal additions to start.
  • Opaque: the feature shouldn't necessarily mirror exactly what is used internally. We may decide to change how things work internally, and that shouldn't affect the public API.
  • Extensible: as we internally refine how to detect different errors, adding relevant details to the public API should be logical.
  • Purposeful: Keep the purpose in mind: to be able to react to certain kinds of errors. Not all errors are that interesting. There is little value in matching on every single possible error variant. Most useful actions are usually: can I retry this? if not, how do I make it pretty to show to a user?
  • Some background reading: https://seanmonstar.com/blog/pattern-matching-and-backwards-compatibility/

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-errorArea: error handlingB-rfcBlocked: More comments would be useful in determine next steps.C-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

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions