mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 22:08:59 +08:00
Apply some defensive programming
We have logs that retrieving the `accessToken` would crash Cura. By adding some defensive programming, in combination with proper error logging the crash no longer happens, and as programmers we have proper logging where the error occurred. CURA-11640
This commit is contained in:
parent
7c00d2f0b3
commit
6f0d2c1f0a
@ -275,7 +275,11 @@ class Account(QObject):
|
||||
|
||||
@pyqtProperty(str, notify=accessTokenChanged)
|
||||
def accessToken(self) -> Optional[str]:
|
||||
return self._authorization_service.getAccessToken()
|
||||
try:
|
||||
return self._authorization_service.getAccessToken()
|
||||
except Exception as e:
|
||||
Logger.error("Failed to get access token: %s", str(e))
|
||||
return None
|
||||
|
||||
@pyqtProperty("QVariantMap", notify = userProfileChanged)
|
||||
def userProfile(self) -> Dict[str, Optional[str]]:
|
||||
|
@ -21,7 +21,7 @@ class UltimakerCloudScope(DefaultUserAgentScope):
|
||||
def __init__(self, application: "CuraApplication"):
|
||||
super().__init__(application)
|
||||
api = application.getCuraAPI()
|
||||
self._account = api.account # type: Account
|
||||
self._account: Account = api.account
|
||||
|
||||
def requestHook(self, request: QNetworkRequest):
|
||||
super().requestHook(request)
|
||||
|
Loading…
x
Reference in New Issue
Block a user