From 817651a80bdb8a2f8cdad28011ab4fdbaceb724d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Thu, 24 Feb 2022 19:57:51 +0100 Subject: [PATCH] utils: Fixed JSON error handling from requets This will be fixed in requests as well, see https://github.com/psf/requests/pull/6036 Fixes WEBLATE-8XX --- weblate/utils/errors.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/weblate/utils/errors.py b/weblate/utils/errors.py index ded2cfb3ca0d..19c2ecad6762 100644 --- a/weblate/utils/errors.py +++ b/weblate/utils/errors.py @@ -68,7 +68,9 @@ def report_error( error = sys.exc_info()[1] - if isinstance(error, JSONDecodeError) and not extra_log: + # Include JSON document if available. It might be missing + # when the error is raised from requests. + if isinstance(error, JSONDecodeError) and not extra_log and hasattr(error, "doc"): extra_log = repr(error.doc) log("%s: %s: %s", cause, error.__class__.__name__, error)