feat(error): add Error::is_connect method

This allows inspecting errors to determine if they are from a client
trying to establish a connection (from the `Connect`).
This commit is contained in:
Sean McArthur
2018-11-29 16:14:24 -08:00
parent fd25129dc0
commit 01f6498355

View File

@@ -97,13 +97,6 @@ pub(crate) enum User {
*/
impl Error {
//TODO(error): should there be these kinds of inspection methods?
//
// - is_io()
// - is_connect()
// - is_closed()
// - etc?
/// Returns true if this was an HTTP parse error.
pub fn is_parse(&self) -> bool {
match self.inner.kind {
@@ -139,6 +132,11 @@ impl Error {
self.inner.kind == Kind::Closed
}
/// Returns true if this was an error from `Connect`.
pub fn is_connect(&self) -> bool {
self.inner.kind == Kind::Connect
}
/// Returns the error's cause.
///
/// This is identical to `Error::cause` except that it provides extra