comparison venv/lib/python2.7/site-packages/requests/exceptions.py @ 0:d67268158946 draft

planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
author bcclaywell
date Mon, 12 Oct 2015 17:43:33 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:d67268158946
1 # -*- coding: utf-8 -*-
2
3 """
4 requests.exceptions
5 ~~~~~~~~~~~~~~~~~~~
6
7 This module contains the set of Requests' exceptions.
8
9 """
10 from .packages.urllib3.exceptions import HTTPError as BaseHTTPError
11
12
13 class RequestException(IOError):
14 """There was an ambiguous exception that occurred while handling your
15 request."""
16
17 def __init__(self, *args, **kwargs):
18 """
19 Initialize RequestException with `request` and `response` objects.
20 """
21 response = kwargs.pop('response', None)
22 self.response = response
23 self.request = kwargs.pop('request', None)
24 if (response is not None and not self.request and
25 hasattr(response, 'request')):
26 self.request = self.response.request
27 super(RequestException, self).__init__(*args, **kwargs)
28
29
30 class HTTPError(RequestException):
31 """An HTTP error occurred."""
32
33
34 class ConnectionError(RequestException):
35 """A Connection error occurred."""
36
37
38 class ProxyError(ConnectionError):
39 """A proxy error occurred."""
40
41
42 class SSLError(ConnectionError):
43 """An SSL error occurred."""
44
45
46 class Timeout(RequestException):
47 """The request timed out.
48
49 Catching this error will catch both
50 :exc:`~requests.exceptions.ConnectTimeout` and
51 :exc:`~requests.exceptions.ReadTimeout` errors.
52 """
53
54
55 class ConnectTimeout(ConnectionError, Timeout):
56 """The request timed out while trying to connect to the remote server.
57
58 Requests that produced this error are safe to retry.
59 """
60
61
62 class ReadTimeout(Timeout):
63 """The server did not send any data in the allotted amount of time."""
64
65
66 class URLRequired(RequestException):
67 """A valid URL is required to make a request."""
68
69
70 class TooManyRedirects(RequestException):
71 """Too many redirects."""
72
73
74 class MissingSchema(RequestException, ValueError):
75 """The URL schema (e.g. http or https) is missing."""
76
77
78 class InvalidSchema(RequestException, ValueError):
79 """See defaults.py for valid schemas."""
80
81
82 class InvalidURL(RequestException, ValueError):
83 """ The URL provided was somehow invalid. """
84
85
86 class ChunkedEncodingError(RequestException):
87 """The server declared chunked encoding but sent an invalid chunk."""
88
89
90 class ContentDecodingError(RequestException, BaseHTTPError):
91 """Failed to decode response content"""
92
93
94 class StreamConsumedError(RequestException, TypeError):
95 """The content for this response was already consumed"""
96
97
98 class RetryError(RequestException):
99 """Custom retries logic failed"""