From c494844a4760d9ac72af246d1f3fb83640d18b76 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Mon, 11 Oct 2021 11:53:10 +0200 Subject: [PATCH] Catch JSON decoding errors in browser.get See: https://progress.opensuse.org/issues/100709 --- openqa_review/browser.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/openqa_review/browser.py b/openqa_review/browser.py index b236718..a18708c 100644 --- a/openqa_review/browser.py +++ b/openqa_review/browser.py @@ -156,7 +156,12 @@ def _get(self, url, as_json=False): # pragma: no cover log.warn(msg) raise DownloadError(msg) - content = r.json() if as_json else r.content.decode("utf8") + try: + content = r.json() if as_json else r.content.decode("utf8") + except JSONDecodeError as e: + msg = "Unable to decode JSON for {}: {}".format(url, r.content.decode("utf8")) + log.warn(msg) + raise DownloadError(msg) return content def json_rpc_get(self, url, method, params, cache=True):