From 479df934dfb12c9224fbce661b4f3891fbb8f892 Mon Sep 17 00:00:00 2001 From: Tristan Cacqueray Date: Wed, 19 Dec 2018 03:24:05 +0000 Subject: [PATCH] Do not decode failed POST response This change logs failed POST text response early to prevent JSONDecodeError exceptions. Change-Id: Iee88fdfb201dfca282e2098d818df7fc77d33784 --- gertty/sync.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gertty/sync.py b/gertty/sync.py index 52eb774..0b77e01 100644 --- a/gertty/sync.py +++ b/gertty/sync.py @@ -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:])