-
-
Notifications
You must be signed in to change notification settings - Fork 278
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
Implement Error::source
for h2::Error
.
#462
base: master
Are you sure you want to change the base?
Conversation
This makes it easier to detect an IO error at the bottom of an error cause chain (e.g. behind a `hyper::Error`). Also, don't implement `std::error::Error` for the private error types, to avoid confusion.
Can we push this forward? In my case, when a client crashes, the server gets an error similar to this.
I want to match the error kind to record the event, but recursively downcasting the error to This is what I end up with: fn match_broken_pipe_error(err: &(dyn std::error::Error + 'static)) -> bool {
if let Some(e) = err.downcast_ref::<h2::Error>() {
if let Some(e) = e.get_io() {
if e.kind() == std::io::ErrorKind::BrokenPipe {
return true;
}
}
}
if let Some(source) = err.source() {
match_broken_pipe_error(source)
} else {
false
}
} The code is much more awkward. |
oof...any update on this? Ran into this myself |
This is still an issue esp while matching on a stream disconnect in tonic: hyperium/tonic#1579 |
I've updated the PR for recent master if anyone would like to review this again :) |
@seanmonstar could we get some feedback on this PR? This would greatly simplify some tonic error handling cases (especially in disambiguating client disconnections): |
This makes it easier to detect an IO error at the bottom of an error
cause chain (e.g. behind a
hyper::Error
).Also, don't implement
std::error::Error
for the private error types,to avoid confusion.