Browse Source

my_activity.py: Handle JSON parse errors

Getting a lot of "(401) Unauthorized" responses for these now. This at
least makes the script not crash.

Change-Id: Ib42ccbdb3326a0918015e9d5e1cc9392a9c1a469
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6049877
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Auto-Submit: Andrew Grieve <agrieve@chromium.org>
Andrew Grieve 8 months ago
parent
commit
0b3c297363
1 changed files with 4 additions and 1 deletions
  1. 4 1
      my_activity.py

+ 4 - 1
my_activity.py

@@ -356,7 +356,10 @@ class MyActivity(object):
         url = url + '?' + query_data
         _, body = http.request(url)
         self.show_progress()
-        content = json.loads(body)
+        try:
+          content = json.loads(body)
+        except json.JSONDecodeError:
+          content = None
         if not content:
             logging.error('Unable to parse %s response from monorail.', project)
             return []