Handle HTTP errors >= 500 and handle HTTP 204 on delete

Change-Id: Ie39355274a75e31142920db3810ff2d78f53a48f
This commit is contained in:
David Moreau Simard 2018-06-25 10:38:01 -04:00
parent b6b4818987
commit 7310b6cea5
1 changed files with 19 additions and 8 deletions

View File

@ -54,13 +54,7 @@ class AraOfflineClient(object):
content_type='application/json'
)
self.log.debug('HTTP {status}: {method} on {endpoint}'.format(
status=response.status_code,
method=method,
endpoint=endpoint
))
if response.status_code not in [200, 201]:
if response.status_code >= 500:
self.log.error(
'Failed to {method} on {endpoint}: {content}'.format(
method=method,
@ -68,7 +62,24 @@ class AraOfflineClient(object):
content=kwargs
)
)
self.log.fatal(response.content)
self.log.debug('HTTP {status}: {method} on {endpoint}'.format(
status=response.status_code,
method=method,
endpoint=endpoint
))
if response.status_code not in [200, 201, 204]:
self.log.error(
'Failed to {method} on {endpoint}: {content}'.format(
method=method,
endpoint=endpoint,
content=kwargs
)
)
if response.status_code == 204:
return response
return response.json()