Skip to content

Commit

Permalink
feat(error): add Error::is_connect method
Browse files Browse the repository at this point in the history
This allows inspecting errors to determine if they are from a client
trying to establish a connection (from the `Connect`).
  • Loading branch information
seanmonstar committed Nov 30, 2018
1 parent fd25129 commit 01f6498
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 01f6498

Please sign in to comment.