Do not decode failed POST response

This change logs failed POST text response early to prevent JSONDecodeError
exceptions.

Change-Id: Iee88fdfb201dfca282e2098d818df7fc77d33784
This commit is contained in:
Tristan Cacqueray 2018-12-19 03:24:05 +00:00
parent c20fef1dec
commit 479df934df
1 changed files with 3 additions and 0 deletions

View File

@ -1490,6 +1490,9 @@ class Sync(object):
self.checkResponse(r)
self.log.debug('Received: %s' % (r.text,))
ret = None
if r.status_code > 400:
raise Exception("POST to %s failed with http code %s (%s)",
path, r.status_code, r.text)
if r.text and len(r.text)>4:
try:
ret = json.loads(r.text[4:])