Skip to content

Commit c2034cd

Browse files
committed
Record error message in TooManyRequestsError
Now, if a TooManyRequestsError is thrown, it will include the error message ('Too Many Requests'), as well as the properties defiend in CleverError.
1 parent 739dd55 commit c2034cd

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

clever/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ class AuthenticationError(CleverError):
139139

140140
class TooManyRequestsError(CleverError):
141141
def __init__(self, message, res):
142-
self.headers = res
142+
super(TooManyRequestsError, self).__init__(message, res['body'], res['code'])
143+
self.http_headers = res['headers']
143144
pass
144145

145146

@@ -219,7 +220,7 @@ def request(self, meth, url, params={}):
219220
return resp, my_auth
220221

221222
def handle_api_error(self, res, resp):
222-
rbody, rcode = res['body'], res['code']
223+
rbody, rheaders, rcode = res['body'], res['headers'], res['code']
223224
try:
224225
error = resp['error']
225226
except (KeyError, TypeError):

0 commit comments

Comments
 (0)