Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGhostkeeper <rubend@tutanota.com>2021-10-12 14:16:28 +0300
committerGhostkeeper <rubend@tutanota.com>2021-10-12 14:16:28 +0300
commita6b6b075ea9911568819f503c742fbf8a0644893 (patch)
tree03459c69de7b99b0ca77f2f89fae117165612e18 /cura/PrinterOutput
parent4ccd4caaad92d1333f7f5288982ca5db5dbc46d6 (diff)
Always provide error message if upload failed
Contributes to issue CURA-8609.
Diffstat (limited to 'cura/PrinterOutput')
-rw-r--r--cura/PrinterOutput/UploadMaterialsJob.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/cura/PrinterOutput/UploadMaterialsJob.py b/cura/PrinterOutput/UploadMaterialsJob.py
index def7ff261f..2beb8057b7 100644
--- a/cura/PrinterOutput/UploadMaterialsJob.py
+++ b/cura/PrinterOutput/UploadMaterialsJob.py
@@ -9,12 +9,15 @@ import enum
import cura.CuraApplication # Imported like this to prevent circular imports.
from cura.UltimakerCloud import UltimakerCloudConstants # To know where the API is.
from cura.UltimakerCloud.UltimakerCloudScope import UltimakerCloudScope # To know how to communicate with this server.
+from UM.i18n import i18nCatalog
from UM.Job import Job
from UM.Logger import Logger
from UM.Signal import Signal
from UM.TaskManagement.HttpRequestManager import HttpRequestManager # To call the API.
from UM.TaskManagement.HttpRequestScope import JsonDecoratorScope
+catalog = i18nCatalog("cura")
+
from typing import Optional, TYPE_CHECKING
if TYPE_CHECKING:
from PyQt5.QtNetwork import QNetworkReply
@@ -66,14 +69,17 @@ class UploadMaterialsJob(Job):
response_data = HttpRequestManager.readJSON(reply)
if response_data is None:
Logger.error(f"Invalid response to material upload request. Could not parse JSON data.")
+ self.setError(UploadMaterialsError(catalog.i18nc("@text:error", "The response from Digital Factory appears to be corrupted.")))
self.setResult(self.Result.FAILED)
return
if "upload_url" not in response_data:
Logger.error(f"Invalid response to material upload request: Missing 'upload_url' field to upload archive to.")
+ self.setError(UploadMaterialsError(catalog.i18nc("@text:error", "The response from Digital Factory is missing important information.")))
self.setResult(self.Result.FAILED)
return
if "material_profile_id" not in response_data:
Logger.error(f"Invalid response to material upload request: Missing 'material_profile_id' to communicate about the materials with the server.")
+ self.setError(UploadMaterialsError(catalog.i18nc("@text:error", "The response from Digital Factory is missing important information.")))
self.setResult(self.Result.FAILED)
return
@@ -92,7 +98,7 @@ class UploadMaterialsJob(Job):
def onUploadCompleted(self, reply: "QNetworkReply", error: Optional["QNetworkReply.NetworkError"]):
if error is not None:
Logger.error(f"Failed to upload material archive: {error}")
- self.setError(UploadMaterialsError(error))
+ self.setError(UploadMaterialsError(catalog.i18nc("@text:error", "Failed to connect to Digital Factory.")))
self.setResult(self.Result.FAILED)
else:
self.setResult(self.Result.SUCCESS)
@@ -101,7 +107,7 @@ class UploadMaterialsJob(Job):
def onError(self, reply: "QNetworkReply", error: Optional["QNetworkReply.NetworkError"]):
Logger.error(f"Failed to upload material archive: {error}")
self.setResult(self.Result.FAILED)
- self.setError(UploadMaterialsError(error))
+ self.setError(UploadMaterialsError(catalog.i18nc("@text:error", "Failed to connect to Digital Factory.")))
self.uploadCompleted.emit(self.getResult(), self.getError())
class UploadMaterialsError(Exception):