From 42abece298562fdedba74c42ef86be3bf4f15a0f Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 23 Jul 2019 14:54:40 +0200 Subject: [PATCH] Fix crash when a corrupted and unkown message was returned This is should be pretty rare, but we got a single crash report for it. --- plugins/Toolbox/src/Toolbox.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/Toolbox/src/Toolbox.py b/plugins/Toolbox/src/Toolbox.py index 698fdbd795..4dabba87a0 100644 --- a/plugins/Toolbox/src/Toolbox.py +++ b/plugins/Toolbox/src/Toolbox.py @@ -655,8 +655,12 @@ class Toolbox(QObject, Extension): # Check if the download was sucessfull if self._download_reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) != 200: - Logger.log("w", "Failed to download package. The following error was returned: %s", json.loads(bytes(self._download_reply.readAll()).decode("utf-8"))) - return + try: + Logger.log("w", "Failed to download package. The following error was returned: %s", json.loads(bytes(self._download_reply.readAll()).decode("utf-8"))) + except json.decoder.JSONDecodeError: + Logger.logException("w", "Failed to download package and failed to parse a response from it") + finally: + return # Must not delete the temporary file on Windows self._temp_plugin_file = tempfile.NamedTemporaryFile(mode = "w+b", suffix = ".curapackage", delete = False) file_path = self._temp_plugin_file.name