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:
@@ -235,7 +235,7 @@ where
|
||||
},
|
||||
Err(_req) => {
|
||||
debug!("connection was not ready");
|
||||
let err = ::Error::new_canceled(Some("connection was not ready"));
|
||||
let err = ::Error::new_canceled().with("connection was not ready");
|
||||
Either::B(future::err(err))
|
||||
}
|
||||
};
|
||||
@@ -262,7 +262,7 @@ where
|
||||
},
|
||||
Err(req) => {
|
||||
debug!("connection was not ready");
|
||||
let err = ::Error::new_canceled(Some("connection was not ready"));
|
||||
let err = ::Error::new_canceled().with("connection was not ready");
|
||||
Either::B(future::err((err, Some(req))))
|
||||
}
|
||||
}
|
||||
@@ -322,7 +322,7 @@ where
|
||||
},
|
||||
Err(req) => {
|
||||
debug!("connection was not ready");
|
||||
let err = ::Error::new_canceled(Some("connection was not ready"));
|
||||
let err = ::Error::new_canceled().with("connection was not ready");
|
||||
Either::B(future::err((err, Some(req))))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user