How to use the zhmcclient._exceptions.ConnectionError function in zhmcclient

To help you get started, we’ve selected a few zhmcclient 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 zhmcclient / python-zhmcclient / zhmcclient / _exceptions.py View on Github external
def __init__(self, msg, details):
        """
        Parameters:

          msg (:term:`string`):
            A human readable message describing the problem.

          details (Exception):
            The original exception describing details about the error.

        ``args[0]`` will be set to the ``msg`` parameter.
        """
        super(ConnectionError, self).__init__(msg)
        self._details = details
github zhmcclient / python-zhmcclient / zhmcclient / _exceptions.py View on Github external
format(self.__class__.__name__, self.args[0])

    def str_def(self):
        """
        :term:`string`: The exception as a string in a Python definition-style
        format, e.g. for parsing by scripts:

        .. code-block:: text

            classname={}; message={};
        """
        return "classname={!r}; message={!r};". \
            format(self.__class__.__name__, self.args[0])


class ConnectTimeout(ConnectionError):
    """
    This exception indicates that a connection to the HMC timed out after
    exhausting the connect retries (see
    :attr:`zhmcclient.RetryTimeoutConfig.connect_retries`).

    Further retrying by the user code is not likely to be successful, unless
    connect retries had been disabled when creating the session (see
    :class:`~zhmcclient.Session`).

    Derived from :exc:`~zhmcclient.ConnectionError`.
    """

    def __init__(self, msg, details, connect_timeout, connect_retries):
        """
        Parameters:
github zhmcclient / python-zhmcclient / zhmcclient / _session.py View on Github external
Handle a :exc:`request.exceptions.RequestException` exception that was
    raised.
    """
    if isinstance(exc, requests.exceptions.ConnectTimeout):
        raise ConnectTimeout(_request_exc_message(exc), exc,
                             retry_timeout_config.connect_timeout,
                             retry_timeout_config.connect_retries)
    elif isinstance(exc, requests.exceptions.ReadTimeout):
        raise ReadTimeout(_request_exc_message(exc), exc,
                          retry_timeout_config.read_timeout,
                          retry_timeout_config.read_retries)
    elif isinstance(exc, requests.exceptions.RetryError):
        raise RetriesExceeded(_request_exc_message(exc), exc,
                              retry_timeout_config.connect_retries)
    else:
        raise ConnectionError(_request_exc_message(exc), exc)
github zhmcclient / python-zhmcclient / zhmcclient / _exceptions.py View on Github external
def str_def(self):
        """
        :term:`string`: The exception as a string in a Python definition-style
        format, e.g. for parsing by scripts:

        .. code-block:: text

            classname={}; read_timeout={}; read_retries={}; message={};
        """
        return "classname={!r}; read_timeout={!r}; read_retries={!r}; " \
            "message={!r};". \
            format(self.__class__.__name__, self.read_timeout,
                   self.read_retries, self.args[0])


class RetriesExceeded(ConnectionError):
    """
    This exception indicates that the maximum number of retries for connecting
    to the HMC, sending HTTP requests or reading HTTP responses was exceeded,
    for reasons other than connect timeouts (see
    :exc:`~zhmcclient.ConnectTimeout`) or read timeouts (see
    :exc:`~zhmcclient.ReadTimeout`).

    Further retrying by the user code is not likely to be successful, unless
    connect or read retries had been disabled when creating the session (see
    :class:`~zhmcclient.Session`).

    Derived from :exc:`~zhmcclient.ConnectionError`.
    """

    def __init__(self, msg, details, connect_retries):
        """
github zhmcclient / python-zhmcclient / zhmcclient / _exceptions.py View on Github external
def str_def(self):
        """
        :term:`string`: The exception as a string in a Python definition-style
        format, e.g. for parsing by scripts:

        .. code-block:: text

            classname={}; connect_timeout={}; connect_retries={}; message={};
        """  # noqa: E501
        return "classname={!r}; connect_timeout={!r}; connect_retries={!r}; " \
            "message={!r};". \
            format(self.__class__.__name__, self.connect_timeout,
                   self.connect_retries, self.args[0])


class ReadTimeout(ConnectionError):
    """
    This exception indicates that reading an HTTP response from the HMC timed
    out after exhausting the read retries (see
    :attr:`zhmcclient.RetryTimeoutConfig.read_retries`).

    Further retrying by the user code is not likely to be successful, unless
    read retries had been disabled when creating the session (see
    :class:`~zhmcclient.Session`).

    Derived from :exc:`~zhmcclient.ConnectionError`.
    """

    def __init__(self, msg, details, read_timeout, read_retries):
        """
        Parameters: