瀏覽代碼

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 月之前
父節點
當前提交
0b3c297363
共有 1 個文件被更改,包括 4 次插入1 次删除
  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 []