- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat(errors): add Error::is_shutdown #2745
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -56,7 +56,6 @@ pub(super) enum Kind { | |||||||
/// The body write was aborted. | ||||||||
BodyWriteAborted, | ||||||||
/// Error calling AsyncWrite::shutdown() | ||||||||
#[cfg(feature = "http1")] | ||||||||
Shutdown, | ||||||||
|
||||||||
/// A general error from h2. | ||||||||
|
@@ -201,6 +200,11 @@ impl Error { | |||||||
self.find_source::<TimedOut>().is_some() | ||||||||
} | ||||||||
|
||||||||
/// Returns true if the error was caused by a shutdown. | ||||||||
pub fn is_shutdown(&self) -> bool { | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. e.g.
Suggested change
Either that, or this should probably also handle h2 goaways? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, that does make me think the name could confuse people. It's not a graceful shutdown, it was an error that occurred when calling It originally was just meant to provide additional context on top of the IO error. Is that context useful on its own? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand what you mean. There is nothing we can do about those errors in the wild (most often they are a "broken pipe" error), so we don't want to log them at all, so we need to discriminate them to ignore them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, it does seem like the context is useful to you. Now the question is, is the name confusing, such that someone might think it's a "graceful shutdown" error received over HTTP/2? Is that a bad thing? Should we hijack the name to make both cases be a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. h2 errors currently are all represented as |
||||||||
matches!(self.inner.kind, Kind::Shutdown) | ||||||||
} | ||||||||
|
||||||||
/// Consumes the error, returning its cause. | ||||||||
pub fn into_cause(self) -> Option<Box<dyn StdError + Send + Sync>> { | ||||||||
self.inner.cause | ||||||||
|
@@ -440,7 +444,6 @@ impl Error { | |||||||
#[cfg(any(feature = "http1", feature = "http2"))] | ||||||||
Kind::BodyWrite => "error writing a body to connection", | ||||||||
Kind::BodyWriteAborted => "body write aborted", | ||||||||
#[cfg(feature = "http1")] | ||||||||
Kind::Shutdown => "error shutting down connection", | ||||||||
#[cfg(feature = "http2")] | ||||||||
Kind::Http2 => "http2 error", | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why change the feature-gate here? Would it be better to clarify the helper?