From 4380cdbd86df87f547e0ba6acfbd0491d8d5eb0b Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 19 Jan 2021 16:31:31 +0100 Subject: [PATCH] Don't crash on malformed JSON structures JSON dictionaries need to have a certain structure such as strings as keys. If that's not correct it gives a TypeError. Don't crash on those; give a similar error message as when the values in the JSON are invalid. --- cura/OAuth2/AuthorizationService.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cura/OAuth2/AuthorizationService.py b/cura/OAuth2/AuthorizationService.py index 9a5c81ae55..a96b05be5f 100644 --- a/cura/OAuth2/AuthorizationService.py +++ b/cura/OAuth2/AuthorizationService.py @@ -1,4 +1,4 @@ -# Copyright (c) 2019 Ultimaker B.V. +# Copyright (c) 2021 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. import json @@ -241,7 +241,7 @@ class AuthorizationService: self._unable_to_get_data_message = Message(i18n_catalog.i18nc("@info", "Unable to reach the Ultimaker account server."), title = i18n_catalog.i18nc("@info:title", "Warning")) self._unable_to_get_data_message.show() - except ValueError: + except (ValueError, TypeError): Logger.logException("w", "Could not load auth data from preferences") def _storeAuthData(self, auth_data: Optional[AuthenticationResponse] = None) -> None: