Expose retry_after attribute of OverLimit exception
Fixes bug 1174469 Change-Id: Ic1e67f6f91d4fe2072ff68dfb36330cd86c1d5b4
This commit is contained in:
parent
201b74b6cc
commit
eae3d724c0
@ -123,6 +123,14 @@ class OverLimit(ClientException):
|
||||
http_status = 413
|
||||
message = "Over limit"
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
try:
|
||||
self.retry_after = int(kwargs.pop('retry_after'))
|
||||
except (KeyError, ValueError):
|
||||
self.retry_after = 0
|
||||
|
||||
super(OverLimit, self).__init__(*args, **kwargs)
|
||||
|
||||
|
||||
# NotImplemented is a python keyword.
|
||||
class HTTPNotImplemented(ClientException):
|
||||
@ -164,6 +172,9 @@ def from_response(response, body, url, method=None):
|
||||
if response.headers:
|
||||
kwargs['request_id'] = response.headers.get('x-compute-request-id')
|
||||
|
||||
if 'retry-after' in response.headers:
|
||||
kwargs['retry_after'] = response.headers.get('retry-after')
|
||||
|
||||
if body:
|
||||
message = "n/a"
|
||||
details = "n/a"
|
||||
|
Loading…
Reference in New Issue
Block a user