Skip to content

Commit 71cb6ee

Browse files
author
hansolshin
committed
Add is_closed method to Error
1 parent df0b7e2 commit 71cb6ee

File tree

1 file changed

+5
-0
lines changed
  • tokio-postgres/src/error

1 file changed

+5
-0
lines changed

tokio-postgres/src/error/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,11 @@ impl Error {
421421
self.source().and_then(|e| e.downcast_ref::<DbError>())
422422
}
423423

424+
/// Determines if the error was associated with closed connection.
425+
pub fn is_closed(&self) -> bool {
426+
self.0.kind == Kind::Closed
427+
}
428+
424429
/// Returns the SQLSTATE error code associated with the error.
425430
///
426431
/// This is a convenience method that downcasts the cause to a `DbError` and returns its code.

0 commit comments

Comments
 (0)