1
2
3
4
5
6 """
7 exception classes.
8 """
9
11 """ default error class """
12 - def __init__(self, msg=None, http_code=None, response=None):
13 self.msg = msg or ''
14 self.status_int = http_code
15 self.response = response
16 Exception.__init__(self)
17
22 message = property(_get_message, _set_message)
23
25 if self.msg:
26 return self.msg
27 try:
28 return str(self.__dict__)
29 except (NameError, ValueError, KeyError), e:
30 return 'Unprintable exception %s: %s' \
31 % (self.__class__.__name__, str(e))
32
33
35 """Exception raised when no resource was found at the given url.
36 """
37
39 """Exception raised when an authorization is required to access to
40 the resource specified.
41 """
42
44 """Exception raised when an unexpected HTTP error is received in response
45 to a request.
46
47
48 The request failed, meaning the remote HTTP server returned a code
49 other than success, unauthorized, or NotFound.
50
51 The exception message attempts to extract the error
52
53 You can get the status code by e.http_code, or see anything about the
54 response via e.response. For example, the entire result body (which is
55 probably an HTML error page) is e.response.body.
56 """
57
59 """Exception raised when the redirection limit is reached."""
60
62 """Exception raised when a request is malformed"""
63
65 """
66 Not a valid url for use with this software.
67 """
68
70 """ Error raised while getting response or decompressing response stream"""
71
72
74 """ raised when proxy error happend"""
75
77 """ Exception returned by the parser when the status line is invalid"""
78 pass
79
81 """ Generic exception returned by the parser """
82 pass
83
85 """ exception raised when remote closed the connection """
86
88 """ raised when a response have already been read """
89
90
91
92
93
94
95
98
103 return "No more data after: %r" % self.buf
104
107 self.req = req
108 self.code = 400
109
111 return "Invalid HTTP request line: %r" % self.req
112
116
118 return "Invalid HTTP method: %r" % self.method
119
123
125 return "Invalid HTTP Version: %s" % self.version
126
130
132 return "Invalid HTTP Status: %s" % self.status
133
137
139 return "Invalid HTTP Header: %r" % self.hdr
140
144
146 return "Invalid HTTP header name: %r" % self.hdr
147
151
153 return "Invalid chunk size: %r" % self.data
154
158
160 return "Invalid chunk terminator is not '\\r\\n': %r" % self.term
161