1
2
3
4
5
6 """
7 exception classes.
8 """
9 from restkit.util import deprecated_property
10
12 """ default error class """
13 - def __init__(self, msg=None, http_code=None, response=None):
14 self.msg = msg or ''
15 self.status = http_code
16 self.response = response
17 Exception.__init__(self)
18
20 """
21 The status as an integer
22 """
23 return self.status
25 self.status = http_code
26 status_int = property(_status_int__get, _status_int__set,
27 doc=_status_int__get.__doc__)
28
29 status_code = deprecated_property(
30 status_int, 'status_code', 'use .status_int instead',
31 warning=False)
32
37 message = property(_get_message, _set_message)
38
40 if self.msg:
41 return self.msg
42 try:
43 return str(self.__dict__)
44 except (NameError, ValueError, KeyError), e:
45 return 'Unprintable exception %s: %s' \
46 % (self.__class__.__name__, str(e))
47
48
50 """Exception raised when no resource was found at the given url.
51 """
52
54 """Exception raised when an authorization is required to access to
55 the resource specified.
56 """
57
59 """Exception raised when an unexpected HTTP error is received in response
60 to a request.
61
62
63 The request failed, meaning the remote HTTP server returned a code
64 other than success, unauthorized, or NotFound.
65
66 The exception message attempts to extract the error
67
68 You can get the status code by e.http_code, or see anything about the
69 response via e.response. For example, the entire result body (which is
70 probably an HTML error page) is e.response.body.
71 """
72
74 """Exception raised when the redirection limit is reached."""
75
77 """Exception raised when a request is malformed"""
78
80 """
81 Not a valid url for use with this software.
82 """
83
85 """ Error raised while getting response or decompressing response stream"""
86
87
89 """ raised when proxy error happend"""
90
92 """ Exception returned by the parser when the status line is invalid"""
93 pass
94
96 """ Generic exception returned by the parser """
97 pass
98