summaryrefslogtreecommitdiffstats
path: root/requests/packages/urllib3/exceptions.py
blob: 47937f79dde7d1f248d0a4bd4d9b14cd0dcf687f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# urllib3/exceptions.py
# Copyright 2008-2011 Andrey Petrov and contributors (see CONTRIBUTORS.txt)
#
# This module is part of urllib3 and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php

## Exceptions

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


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


class MaxRetryError(HTTPError):
    "Raised when the maximum number of retries is exceeded."
    def __init__(self, url):
        HTTPError.__init__(self, "Max retries exceeded for url: %s" % url)
        self.url = url


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


class HostChangedError(HTTPError):
    "Raised when an existing pool gets a request for a foreign host."
    def __init__(self, original_host, new_url, retries=3):
        HTTPError.__init__(self,
            "Connection pool with host '%s' tried to open a foreign host: %s" %
            (original_host, new_url))

        self.original_host = original_host
        self.new_url = new_url
        self.retries = retries


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