hyperium / hyperium/hyper

Create a hyper::error::Code type

Open
#2,845 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-error B-rfc C-feature E-medium
Dominant language
Rust
Stars
16.3k
Forks
1.8k
Avg merge
1d 22h
Merged PRs (30d)
14

Description

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/

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the existing hyper::error API and the error section of docs/ROADMAP.md. Compare an opaque struct with a non-exhaustive enum, then propose a conservative, extensible public Code API for errors useful to callers and HTTP/2 or HTTP/3 handling. Done means the design is agreed and the public constants and representation are specified without exposing internal details.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.