From 222f8e6cdb11c3dfe44cbaa07cec8035ad9424d4 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 18 Feb 2019 10:38:39 +0100 Subject: [PATCH] Prevent crash for backup plugin if there is no internet connection --- plugins/CuraDrive/src/DriveApiService.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/plugins/CuraDrive/src/DriveApiService.py b/plugins/CuraDrive/src/DriveApiService.py index 7c1f8faa83..6a828e32d6 100644 --- a/plugins/CuraDrive/src/DriveApiService.py +++ b/plugins/CuraDrive/src/DriveApiService.py @@ -40,10 +40,13 @@ class DriveApiService: if not access_token: Logger.log("w", "Could not get access token.") return [] - - backup_list_request = requests.get(self.BACKUP_URL, headers = { - "Authorization": "Bearer {}".format(access_token) - }) + try: + backup_list_request = requests.get(self.BACKUP_URL, headers = { + "Authorization": "Bearer {}".format(access_token) + }) + except requests.exceptions.ConnectionError: + Logger.log("w", "Unable to connect with the server.") + return [] # HTTP status 300s mean redirection. 400s and 500s are errors. # Technically 300s are not errors, but the use case here relies on "requests" to handle redirects automatically.