refactor(error): improve organization of Error kinds
- Placed all cases of "unexpected bytes" errors into the `UnexpectedMessage` variant. - Placed all cases of "unexpected EOF" errors into the `IncompleteMessage` variant. Description is now generic about "connection closed before message completed", instead of mentioning "request" or "response. - Added `Error::is_incomplete_message()` accessor to help checking for unexpected closures. - Renamed some variants to be clearer when viewing the `Debug` format. - Collected all "user" errors into an internal `User` enum, to prevent forgetting to update the `is_user()` method.
This commit is contained in:
@@ -498,7 +498,7 @@ where C: Connect + Sync + 'static,
|
||||
let connecting = match pool.connecting(&pool_key, ver) {
|
||||
Some(lock) => lock,
|
||||
None => {
|
||||
let canceled = ::Error::new_canceled(Some("HTTP/2 connection in progress"));
|
||||
let canceled = ::Error::new_canceled().with("HTTP/2 connection in progress");
|
||||
return Either::B(future::err(canceled));
|
||||
}
|
||||
};
|
||||
@@ -517,7 +517,7 @@ where C: Connect + Sync + 'static,
|
||||
None => {
|
||||
// Another connection has already upgraded,
|
||||
// the pool checkout should finish up for us.
|
||||
let canceled = ::Error::new_canceled(Some("ALPN upgraded to HTTP/2"));
|
||||
let canceled = ::Error::new_canceled().with("ALPN upgraded to HTTP/2");
|
||||
return Either::B(future::err(canceled));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user