How to use the zulip.zulip.__init__.UnrecoverableNetworkError function in zulip

To help you get started, we’ve selected a few zulip examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zulip / python-zulip-api / zulip / zulip / __init__.py View on Github external
**kwargs)

                self.has_connected = True

                # On 50x errors, try again after a short sleep
                if str(res.status_code).startswith('5'):
                    if error_retry(" (server %s)" % (res.status_code,)):
                        continue
                    # Otherwise fall through and process the python-requests error normally
            except (requests.exceptions.Timeout, requests.exceptions.SSLError) as e:
                # Timeouts are either a Timeout or an SSLError; we
                # want the later exception handlers to deal with any
                # non-timeout other SSLErrors
                if (isinstance(e, requests.exceptions.SSLError) and
                        str(e) != "The read operation timed out"):
                    raise UnrecoverableNetworkError('SSL Error')
                if longpolling:
                    # When longpolling, we expect the timeout to fire,
                    # and the correct response is to just retry
                    continue
                else:
                    end_error_retry(False)
                    return {'msg': "Connection error:\n%s" % traceback.format_exc(),
                            "result": "connection-error"}
            except requests.exceptions.ConnectionError:
                if not self.has_connected:
                    # If we have never successfully connected to the server, don't
                    # go into retry logic, because the most likely scenario here is
                    # that somebody just hasn't started their server, or they passed
                    # in an invalid site.
                    raise UnrecoverableNetworkError('cannot connect to server ' + self.base_url)
github zulip / python-zulip-api / zulip / zulip / __init__.py View on Github external
raise UnrecoverableNetworkError('SSL Error')
                if longpolling:
                    # When longpolling, we expect the timeout to fire,
                    # and the correct response is to just retry
                    continue
                else:
                    end_error_retry(False)
                    return {'msg': "Connection error:\n%s" % traceback.format_exc(),
                            "result": "connection-error"}
            except requests.exceptions.ConnectionError:
                if not self.has_connected:
                    # If we have never successfully connected to the server, don't
                    # go into retry logic, because the most likely scenario here is
                    # that somebody just hasn't started their server, or they passed
                    # in an invalid site.
                    raise UnrecoverableNetworkError('cannot connect to server ' + self.base_url)

                if error_retry(""):
                    continue
                end_error_retry(False)
                return {'msg': "Connection error:\n%s" % traceback.format_exc(),
                        "result": "connection-error"}
            except Exception:
                # We'll split this out into more cases as we encounter new bugs.
                return {'msg': "Unexpected error:\n%s" % traceback.format_exc(),
                        "result": "unexpected-error"}

            try:
                if requests_json_is_function:
                    json_result = res.json()
                else:
                    json_result = res.json