def METHOD_NAME(self, e, connection, cursor):
    if isinstance(e, (self.dbapi.OperationalError,
                      self.dbapi.ProgrammingError)):
        msg = str(e)
        return ('Unable to complete network request to host' in msg or
                'Invalid connection state' in msg or
                'Invalid cursor state' in msg or
                'connection shutdown' in msg)
    else:
        return False