How to use the requests3.core._http.exceptions.HTTPError function in requests3

To help you get started, we’ve selected a few requests3 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 psf / requests / requests3 / core / _http / exceptions.py View on Github external
class UnrewindableBodyError(HTTPError):
    "urllib3 encountered an error when trying to rewind a body"
    pass


class FailedTunnelError(HTTPError):
    """
    An attempt was made to set up a CONNECT tunnel, but that attempt failed.
    """

    def __init__(self, message, response):
        super(FailedTunnelError, self).__init__(message)
        self.response = response


class InvalidBodyError(HTTPError):
    """
    An attempt was made to send a request with a body object that urllib3 does
    not support.
    """
    pass
github psf / requests / requests3 / core / _http / exceptions.py View on Github external
:param pool: The connection pool
    :type pool: :class:`~urllib3.connectionpool.HTTPConnectionPool`
    :param string url: The requested Url
    :param exceptions.Exception reason: The underlying error

    """

    def __init__(self, pool, url, reason=None):
        self.reason = reason
        message = "Max retries exceeded with url: %s (Caused by %r)" % (
            url, reason
        )
        RequestError.__init__(self, pool, url, message)


class TimeoutStateError(HTTPError):
    """ Raised when passing an invalid state to a timeout """
    pass


class TimeoutError(HTTPError):
    """ Raised when a socket timeout error occurs.

    Catching this error will catch both :exc:`ReadTimeoutErrors
    ` and :exc:`ConnectTimeoutErrors `.
    """
    pass


class ReadTimeoutError(TimeoutError, RequestError):
    "Raised when a socket timeout occurs while receiving data from a server"
    pass
github psf / requests / requests3 / core / _http / exceptions.py View on Github external
class LocationValueError(ValueError, HTTPError):
    "Raised when there is something wrong with a given URL input."
    pass


class LocationParseError(LocationValueError):
    "Raised when get_host or similar fails to parse the URL input."

    def __init__(self, location):
        message = "Failed to parse: %s" % location
        HTTPError.__init__(self, message)
        self.location = location


class ResponseError(HTTPError):
    "Used as a container for an error reason supplied in a MaxRetryError."
    GENERIC_ERROR = 'too many error responses'
    SPECIFIC_ERROR = 'too many {status_code} error responses'


class SecurityWarning(HTTPWarning):
    "Warned when perfoming security reducing actions"
    pass


class SubjectAltNameWarning(SecurityWarning):
    "Warned when connecting to a host with a certificate missing a SAN."
    pass


class InsecureRequestWarning(SecurityWarning):
github psf / requests / requests3 / core / _http / exceptions.py View on Github external
class NewConnectionError(ConnectTimeoutError, PoolError):
    "Raised when we fail to establish a new connection. Usually ECONNREFUSED."
    pass


class EmptyPoolError(PoolError):
    "Raised when a pool runs out of connections and no more are allowed."
    pass


class ClosedPoolError(PoolError):
    "Raised when a request enters a pool after the pool has been closed."
    pass


class LocationValueError(ValueError, HTTPError):
    "Raised when there is something wrong with a given URL input."
    pass


class LocationParseError(LocationValueError):
    "Raised when get_host or similar fails to parse the URL input."

    def __init__(self, location):
        message = "Failed to parse: %s" % location
        HTTPError.__init__(self, message)
        self.location = location


class ResponseError(HTTPError):
    "Used as a container for an error reason supplied in a MaxRetryError."
    GENERIC_ERROR = 'too many error responses'
github psf / requests / requests3 / core / _http / exceptions.py View on Github external
def __init__(self, version):
        message = "HTTP version {} is unsupported".format(version)
        super(BadVersionError, self).__init__(message)


class ProxySchemeUnknown(AssertionError, ValueError):
    "ProxyManager does not support the supplied scheme"

    # TODO(t-8ch): Stop inheriting from AssertionError in v2.0.
    def __init__(self, scheme):
        message = "Not supported proxy scheme %s" % scheme
        super(ProxySchemeUnknown, self).__init__(message)


class HeaderParsingError(HTTPError):
    "Raised by assert_header_parsing, but we convert it to a log.warning statement."

    def __init__(self, defects, unparsed_data):
        message = '%s, unparsed data: %r' % (
            defects or 'Unknown', unparsed_data
        )
        super(HeaderParsingError, self).__init__(message)


class UnrewindableBodyError(HTTPError):
    "urllib3 encountered an error when trying to rewind a body"
    pass


class FailedTunnelError(HTTPError):
    """
github psf / requests / requests3 / core / _http / exceptions.py View on Github external
def __reduce__(self):
        # For pickling purposes.
        return self.__class__, (None, self.url, None)


class SSLError(HTTPError):
    "Raised when SSL certificate fails in an HTTPS connection."
    pass


class ProxyError(HTTPError):
    "Raised when the connection to a proxy fails."
    pass


class DecodeError(HTTPError):
    "Raised when automatic decoding based on Content-Type fails."
    pass


class ProtocolError(HTTPError):
    "Raised when something unexpected happens mid-request/response."
    pass


# : Renamed to ProtocolError but aliased for backwards compatibility.
ConnectionError = ProtocolError


# Leaf Exceptions
class MaxRetryError(RequestError):
    """Raised when the maximum number of retries is exceeded.
github psf / requests / requests3 / core / _http / exceptions.py View on Github external
class HeaderParsingError(HTTPError):
    "Raised by assert_header_parsing, but we convert it to a log.warning statement."

    def __init__(self, defects, unparsed_data):
        message = '%s, unparsed data: %r' % (
            defects or 'Unknown', unparsed_data
        )
        super(HeaderParsingError, self).__init__(message)


class UnrewindableBodyError(HTTPError):
    "urllib3 encountered an error when trying to rewind a body"
    pass


class FailedTunnelError(HTTPError):
    """
    An attempt was made to set up a CONNECT tunnel, but that attempt failed.
    """

    def __init__(self, message, response):
        super(FailedTunnelError, self).__init__(message)
        self.response = response


class InvalidBodyError(HTTPError):
    """
    An attempt was made to send a request with a body object that urllib3 does
    not support.
    """
    pass
github psf / requests / requests3 / core / _http / exceptions.py View on Github external
from __future__ import absolute_import



# Base Exceptions
class HTTPError(Exception):
    "Base exception used by this module."
    pass


class HTTPWarning(Warning):
    "Base warning used by this module."
    pass


class PoolError(HTTPError):
    "Base exception for errors caused within a pool."

    def __init__(self, pool, message):
        self.pool = pool
        HTTPError.__init__(self, "%s: %s" % (pool, message))

    def __reduce__(self):
        # For pickling purposes.
        return self.__class__, (None, None)


class RequestError(PoolError):
    "Base exception for PoolErrors that have associated URLs."

    def __init__(self, pool, url, message):
        self.url = url
github psf / requests / requests3 / core / _http / exceptions.py View on Github external
"""

    def __init__(self, pool, url, reason=None):
        self.reason = reason
        message = "Max retries exceeded with url: %s (Caused by %r)" % (
            url, reason
        )
        RequestError.__init__(self, pool, url, message)


class TimeoutStateError(HTTPError):
    """ Raised when passing an invalid state to a timeout """
    pass


class TimeoutError(HTTPError):
    """ Raised when a socket timeout error occurs.

    Catching this error will catch both :exc:`ReadTimeoutErrors
    ` and :exc:`ConnectTimeoutErrors `.
    """
    pass


class ReadTimeoutError(TimeoutError, RequestError):
    "Raised when a socket timeout occurs while receiving data from a server"
    pass




# This timeout error does not have a URL attached and needs to inherit from the
github psf / requests / requests3 / core / _http / exceptions.py View on Github external
class SNIMissingWarning(HTTPWarning):
    "Warned when making a HTTPS request without SNI available."
    pass


class DependencyWarning(HTTPWarning):
    """
    Warned when an attempt is made to import a module with missing optional
    dependencies.
    """
    pass


class InvalidHeader(HTTPError):
    "The header provided was somehow invalid."
    pass


class BadVersionError(ProtocolError):
    """
    The HTTP version in the response is unsupported.
    """

    def __init__(self, version):
        message = "HTTP version {} is unsupported".format(version)
        super(BadVersionError, self).__init__(message)


class ProxySchemeUnknown(AssertionError, ValueError):
    "ProxyManager does not support the supplied scheme"