diff --git a/tokio-postgres/src/error/mod.rs b/tokio-postgres/src/error/mod.rs index ee29a1dbb..47a31e793 100644 --- a/tokio-postgres/src/error/mod.rs +++ b/tokio-postgres/src/error/mod.rs @@ -421,6 +421,11 @@ impl Error { self.source().and_then(|e| e.downcast_ref::()) } + /// Determines if the error was associated with closed connection. + pub fn is_closed(&self) -> bool { + self.0.kind == Kind::Closed + } + /// Returns the SQLSTATE error code associated with the error. /// /// This is a convenience method that downcasts the cause to a `DbError` and returns its code.