1
2
3
4
5
6 """
7 exception classes.
8 """
9
11 """ default error class """
12
13 status_int = None
14
15 - def __init__(self, msg=None, http_code=None, response=None):
20
25 message = property(_get_message, _set_message)
26
28 if self.msg:
29 return self.msg
30 try:
31 return str(self.__dict__)
32 except (NameError, ValueError, KeyError), e:
33 return 'Unprintable exception %s: %s' \
34 % (self.__class__.__name__, str(e))
35
36
38 """Exception raised when no resource was found at the given url.
39 """
40 status_int = 404
41
43 """Exception raised when an authorization is required to access to
44 the resource specified.
45 """
46
48 """
49 http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.11
50 """
51 status_int = 410
52
54 """Exception raised when an unexpected HTTP error is received in response
55 to a request.
56
57
58 The request failed, meaning the remote HTTP server returned a code
59 other than success, unauthorized, or NotFound.
60
61 The exception message attempts to extract the error
62
63 You can get the status code by e.status_int, or see anything about the
64 response via e.response. For example, the entire result body (which is
65 probably an HTML error page) is e.response.body.
66 """
67
69 """Exception raised when the redirection limit is reached."""
70
72 """Exception raised when a request is malformed"""
73
75 """ Exception raised on socket timeout """
76
78 """
79 Not a valid url for use with this software.
80 """
81
83 """ Error raised while getting response or decompressing response stream"""
84
85
87 """ raised when proxy error happend"""
88
90 """ Exception returned by the parser when the status line is invalid"""
91 pass
92
94 """ Generic exception returned by the parser """
95 pass
96
98 """ exception raised when remote closed the connection """
99
101 """ raised when a response have already been read """
102
105
106
107
108
109
112
117 return "No more data after: %r" % self.buf
118
121 self.req = req
122 self.code = 400
123
125 return "Invalid HTTP request line: %r" % self.req
126
130
132 return "Invalid HTTP method: %r" % self.method
133
137
139 return "Invalid HTTP Version: %s" % self.version
140
144
146 return "Invalid HTTP Status: %s" % self.status
147
151
153 return "Invalid HTTP Header: %r" % self.hdr
154
158
160 return "Invalid HTTP header name: %r" % self.hdr
161
165
167 return "Invalid chunk size: %r" % self.data
168
172
174 return "Invalid chunk terminator is not '\\r\\n': %r" % self.term
175
177 """ exception raised when we gore more headers than
178 max_header_count
179 """
180