Merge pull request #739 from the-anonymous009/error_kind

Make error kind public
This commit is contained in:
Steven Fackler 2021-03-28 20:26:02 -04:00 committed by GitHub
commit b0492d45eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -421,6 +421,11 @@ impl Error {
self.source().and_then(|e| e.downcast_ref::<DbError>()) self.source().and_then(|e| e.downcast_ref::<DbError>())
} }
/// 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. /// 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. /// This is a convenience method that downcasts the cause to a `DbError` and returns its code.