Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document that Error::source() types can not be depended on #2843

Closed
seanmonstar opened this issue May 20, 2022 · 5 comments · Fixed by #3318
Closed

Document that Error::source() types can not be depended on #2843

seanmonstar opened this issue May 20, 2022 · 5 comments · Fixed by #3318
Labels
A-docs Area: documentation. A-error Area: error handling B-breaking-change Blocked: this is an "API breaking change". C-feature Category: feature. This is adding a new feature. E-easy Effort: easy. A task that would be a great starting point for a new contributor.
Milestone

Comments

@seanmonstar
Copy link
Member

seanmonstar commented May 20, 2022

All sources/causes in hyper::Error should be wrapped in a private Opaque type that still prints (impl Debug and impl Display) the message, but makes the type no longer leak through err.downcast::<Blah>().

@seanmonstar seanmonstar added C-feature Category: feature. This is adding a new feature. E-medium Effort: medium. Some knowledge of how hyper internal works would be useful. A-error Area: error handling labels May 20, 2022
@seanmonstar seanmonstar added this to the 1.0 milestone May 20, 2022
@sfackler
Copy link
Contributor

Is it not going to expose sources either? Since the opaque wrapping can only happen at the first level

@seanmonstar
Copy link
Member Author

I suppose it "couldn't" expose the next source, since it can't wrap a reference, and exposing it would potentially include unstable dependencies... If the second option in #2844 happens, the unexposed sources would still be printable at least.

@seanmonstar
Copy link
Member Author

I filed a proposal for the error handling WG, since that could affect the formatting needed for an "opaque" type.

@seanmonstar seanmonstar modified the milestones: 1.0 RC1, 1.0 Final Sep 8, 2022
@seanmonstar seanmonstar moved this from Blocked to Todo in hyper 1.0 May 18, 2023
@seanmonstar seanmonstar added the B-breaking-change Blocked: this is an "API breaking change". label Aug 31, 2023
@seanmonstar
Copy link
Member Author

I suppose a question to consider is: is it fair to simply document "The types in Error::source() are not part of the public API, and are subject to change at any time"?

@davidpdrsn
Copy link
Member

imo that's fine. It's what axum does for extractor rejections. While not great I think its pragmatic and acceptable.

@seanmonstar seanmonstar changed the title Make Error::source() types that come from unstable dependencies wrapped in an Opaque type Document that Error::source() types can not be depended on Sep 18, 2023
@seanmonstar seanmonstar added A-docs Area: documentation. E-easy Effort: easy. A task that would be a great starting point for a new contributor. B-breaking-change Blocked: this is an "API breaking change". and removed E-medium Effort: medium. Some knowledge of how hyper internal works would be useful. B-breaking-change Blocked: this is an "API breaking change". labels Sep 18, 2023
seanmonstar added a commit that referenced this issue Sep 18, 2023
Document that the exact types returned in the erased errors of
`Error::source()` may change at any moment, and cannot be depended on.

Closes #2843

BREAKING CHANGE: Do not build any logic depending on the exact types of
  an `Error::source()`. They are only for debugging.
seanmonstar added a commit that referenced this issue Sep 18, 2023
Document that the exact types returned in the erased errors of
`Error::source()` may change at any moment, and cannot be depended on.

Closes #2843

BREAKING CHANGE: Do not build any logic depending on the exact types of
  an `Error::source()`. They are only for debugging.
@seanmonstar seanmonstar moved this from Todo to In Progress in hyper 1.0 Sep 18, 2023
seanmonstar added a commit that referenced this issue Sep 18, 2023
Document that the exact types returned in the erased errors of
`Error::source()` may change at any moment, and cannot be depended on.

Closes #2843

BREAKING CHANGE: Do not build any logic depending on the exact types of
  an `Error::source()`. They are only for debugging.
@github-project-automation github-project-automation bot moved this from In Progress to Done in hyper 1.0 Sep 18, 2023
@seanmonstar seanmonstar moved this from Done to Blocked in hyper 1.0 Sep 30, 2023
@seanmonstar seanmonstar moved this from Blocked to Done in hyper 1.0 Sep 30, 2023
0xE282B0 pushed a commit to 0xE282B0/hyper that referenced this issue Jan 12, 2024
…3318)

Document that the exact types returned in the erased errors of
`Error::source()` may change at any moment, and cannot be depended on.

Closes hyperium#2843

BREAKING CHANGE: Do not build any logic depending on the exact types of
  an `Error::source()`. They are only for debugging.
0xE282B0 pushed a commit to 0xE282B0/hyper that referenced this issue Jan 16, 2024
…3318)

Document that the exact types returned in the erased errors of
`Error::source()` may change at any moment, and cannot be depended on.

Closes hyperium#2843

BREAKING CHANGE: Do not build any logic depending on the exact types of
  an `Error::source()`. They are only for debugging.

Signed-off-by: Sven Pfennig <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation. A-error Area: error handling B-breaking-change Blocked: this is an "API breaking change". C-feature Category: feature. This is adding a new feature. E-easy Effort: easy. A task that would be a great starting point for a new contributor.
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants