Implement Error::source for h2::Error.#462
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): |
|
Any update this?? @seanmonstar |
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::Errorfor the private error types,to avoid confusion.