From 71748bff8d2604b9be761dcc0ba5563df1d0764f Mon Sep 17 00:00:00 2001 From: Konstantinos Karmas Date: Wed, 11 Aug 2021 17:05:36 +0200 Subject: [PATCH] Don't crash if the reply cannot be loaded Fixes Sentry issue CURA-2RQ --- plugins/Toolbox/src/Toolbox.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/Toolbox/src/Toolbox.py b/plugins/Toolbox/src/Toolbox.py index c238d3f009..b91b580779 100644 --- a/plugins/Toolbox/src/Toolbox.py +++ b/plugins/Toolbox/src/Toolbox.py @@ -651,8 +651,11 @@ class Toolbox(QObject, Extension): self.resetDownload() if reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) != 200: - Logger.log("w", "Failed to download package. The following error was returned: %s", - json.loads(reply.readAll().data().decode("utf-8"))) + try: + reply_error = json.loads(reply.readAll().data().decode("utf-8")) + except Exception as e: + reply_error = str(e) + Logger.log("w", "Failed to download package. The following error was returned: %s", reply_error) return # Must not delete the temporary file on Windows self._temp_plugin_file = tempfile.NamedTemporaryFile(mode = "w+b", suffix = ".curapackage", delete = False)