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 """Exception raised when an unexpected HTTP error is received in response
49 to a request.
50
51
52 The request failed, meaning the remote HTTP server returned a code
53 other than success, unauthorized, or NotFound.
54
55 The exception message attempts to extract the error
56
57 You can get the status code by e.http_code, or see anything about the
58 response via e.response. For example, the entire result body (which is
59 probably an HTML error page) is e.response.body.
60 """
61
63 """Exception raised when the redirection limit is reached."""
64
66 """Exception raised when a request is malformed"""
67
69 """ Exception raised on socket timeout """
70
72 """
73 Not a valid url for use with this software.
74 """
75
77 """ Error raised while getting response or decompressing response stream"""
78
79
81 """ raised when proxy error happend"""
82
84 """ Exception returned by the parser when the status line is invalid"""
85 pass
86
88 """ Generic exception returned by the parser """
89 pass
90
92 """ exception raised when remote closed the connection """
93
95 """ raised when a response have already been read """
96
97
98
99
100
101
102
105
110 return "No more data after: %r" % self.buf
111
114 self.req = req
115 self.code = 400
116
118 return "Invalid HTTP request line: %r" % self.req
119
123
125 return "Invalid HTTP method: %r" % self.method
126
130
132 return "Invalid HTTP Version: %s" % self.version
133
137
139 return "Invalid HTTP Status: %s" % self.status
140
144
146 return "Invalid HTTP Header: %r" % self.hdr
147
151
153 return "Invalid HTTP header name: %r" % self.hdr
154
158
160 return "Invalid chunk size: %r" % self.data
161
165
167 return "Invalid chunk terminator is not '\\r\\n': %r" % self.term
168