Coverage for /home/martinb/.local/share/virtualenvs/camcops/lib/python3.6/site-packages/requests/exceptions.py : 100%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# -*- coding: utf-8 -*-
3"""
4requests.exceptions
5~~~~~~~~~~~~~~~~~~~
7This module contains the set of Requests' exceptions.
8"""
9from urllib3.exceptions import HTTPError as BaseHTTPError
12class RequestException(IOError):
13 """There was an ambiguous exception that occurred while handling your
14 request.
15 """
17 def __init__(self, *args, **kwargs):
18 """Initialize RequestException with `request` and `response` objects."""
19 response = kwargs.pop('response', None)
20 self.response = response
21 self.request = kwargs.pop('request', None)
22 if (response is not None and not self.request and
23 hasattr(response, 'request')):
24 self.request = self.response.request
25 super(RequestException, self).__init__(*args, **kwargs)
28class HTTPError(RequestException):
29 """An HTTP error occurred."""
32class ConnectionError(RequestException):
33 """A Connection error occurred."""
36class ProxyError(ConnectionError):
37 """A proxy error occurred."""
40class SSLError(ConnectionError):
41 """An SSL error occurred."""
44class Timeout(RequestException):
45 """The request timed out.
47 Catching this error will catch both
48 :exc:`~requests.exceptions.ConnectTimeout` and
49 :exc:`~requests.exceptions.ReadTimeout` errors.
50 """
53class ConnectTimeout(ConnectionError, Timeout):
54 """The request timed out while trying to connect to the remote server.
56 Requests that produced this error are safe to retry.
57 """
60class ReadTimeout(Timeout):
61 """The server did not send any data in the allotted amount of time."""
64class URLRequired(RequestException):
65 """A valid URL is required to make a request."""
68class TooManyRedirects(RequestException):
69 """Too many redirects."""
72class MissingSchema(RequestException, ValueError):
73 """The URL schema (e.g. http or https) is missing."""
76class InvalidSchema(RequestException, ValueError):
77 """See defaults.py for valid schemas."""
80class InvalidURL(RequestException, ValueError):
81 """The URL provided was somehow invalid."""
84class InvalidHeader(RequestException, ValueError):
85 """The header value provided was somehow invalid."""
88class InvalidProxyURL(InvalidURL):
89 """The proxy URL provided is invalid."""
92class ChunkedEncodingError(RequestException):
93 """The server declared chunked encoding but sent an invalid chunk."""
96class ContentDecodingError(RequestException, BaseHTTPError):
97 """Failed to decode response content."""
100class StreamConsumedError(RequestException, TypeError):
101 """The content for this response was already consumed."""
104class RetryError(RequestException):
105 """Custom retries logic failed"""
108class UnrewindableBodyError(RequestException):
109 """Requests encountered an error when trying to rewind a body."""
111# Warnings
114class RequestsWarning(Warning):
115 """Base warning for Requests."""
118class FileModeWarning(RequestsWarning, DeprecationWarning):
119 """A file was opened in text mode, but Requests determined its binary length."""
122class RequestsDependencyWarning(RequestsWarning):
123 """An imported dependency doesn't match the expected version range."""