aboutsummaryrefslogtreecommitdiffstats
path: root/netlib/http/exceptions.py
blob: 7cd26c122fc1ab0e42df1707c3e44717a775836c (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
from netlib import odict

class HttpError(Exception):
    def __init__(self, code, message):
        super(HttpError, self).__init__(message)
        self.code = code


class HttpErrorConnClosed(HttpError):
    pass


class HttpAuthenticationError(Exception):
    def __init__(self, auth_headers=None):
        super(HttpAuthenticationError, self).__init__(
            "Proxy Authentication Required"
        )
        if isinstance(auth_headers, dict):
            auth_headers = odict.ODictCaseless(auth_headers.items())
        self.headers = auth_headers
        self.code = 407

    def __repr__(self):
        return "Proxy Authentication Required"