Handle HTTP errors >= 500 and handle HTTP 204 on delete
Change-Id: Ie39355274a75e31142920db3810ff2d78f53a48f
This commit is contained in:
parent
b6b4818987
commit
7310b6cea5
|
@ -54,13 +54,7 @@ class AraOfflineClient(object):
|
||||||
content_type='application/json'
|
content_type='application/json'
|
||||||
)
|
)
|
||||||
|
|
||||||
self.log.debug('HTTP {status}: {method} on {endpoint}'.format(
|
if response.status_code >= 500:
|
||||||
status=response.status_code,
|
|
||||||
method=method,
|
|
||||||
endpoint=endpoint
|
|
||||||
))
|
|
||||||
|
|
||||||
if response.status_code not in [200, 201]:
|
|
||||||
self.log.error(
|
self.log.error(
|
||||||
'Failed to {method} on {endpoint}: {content}'.format(
|
'Failed to {method} on {endpoint}: {content}'.format(
|
||||||
method=method,
|
method=method,
|
||||||
|
@ -68,7 +62,24 @@ class AraOfflineClient(object):
|
||||||
content=kwargs
|
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()
|
return response.json()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue