Skip to content

feat(client/dispatch): TrySendError<T>: std::error::Error #3922

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cratelyn
Copy link
Member

this commit introduces a std::error::Error implementation for hyper::client::conn::TrySendError.

this allows callers of
hyper::client::conn::http2::SendRequest::try_send_request() or hyper::client::conn::http1::SendRequest::try_send_request() to box a TrySendError<T> without discarding a potentially recovered message.

a std::fmt::Display implementation is added in this commit, because it is a prerequisite for implementations of std::error::Error.

for some previous discussion on this topic, see "other options" here: #3883 (comment).

see also:

this commit introduces a `std::error::Error` implementation for
`hyper::client::conn::TrySendError`.

this allows callers of
`hyper::client::conn::http2::SendRequest::try_send_request()` or
`hyper::client::conn::http1::SendRequest::try_send_request()` to box a
`TrySendError<T>` without discarding a potentially recovered message.

a `std::fmt::Display` implementation is added in this commit, because it
is a prerequisite for implementations of `std::error::Error`.

for some previous discussion on this topic, see "_other options_" here:
hyperium#3883 (comment).

Ref: hyperium#3883
Ref: hyperium#3892
Signed-off-by: katelyn martin <[email protected]>
@cratelyn cratelyn self-assigned this Jul 29, 2025
@cratelyn cratelyn added A-client Area: client. C-feature Category: feature. This is adding a new feature. labels Jul 29, 2025
@cratelyn cratelyn requested a review from seanmonstar July 29, 2025 03:18
impl<T> fmt::Display for TrySendError<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let Self { error, message: _ } = self;
write!(f, "{}", error)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reminds of the guidelines that an error should either be in the Display, or the source, but not both...

I do think a message like error trying to send request before it was consumed is less useful...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-client Area: client. C-feature Category: feature. This is adding a new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants