Browse Source

Do not decode failed POST response

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

Change-Id: Iee88fdfb201dfca282e2098d818df7fc77d33784
Tristan Cacqueray 4 months ago
parent
commit
479df934df
1 changed files with 3 additions and 0 deletions
  1. 3
    0
      gertty/sync.py

+ 3
- 0
gertty/sync.py View File

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

Loading…
Cancel
Save