Show more information about errors we're getting

Show the error code we received in the GUI, and allow expansion for different types of errors.

Contributes to issue CURA-8609.
This commit is contained in:
Ghostkeeper 2021-10-12 11:30:12 +02:00
parent 025ef743ee
commit 125c80430b
No known key found for this signature in database
GPG key ID: 68F39EA88EEED5FF
2 changed files with 16 additions and 5 deletions

View file

@ -81,12 +81,20 @@ 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.setResult(self.Result.FAILED)
else:
self.setResult(self.Result.SUCCESS)
self.uploadCompleted.emit(self.getResult())
self.uploadCompleted.emit(self.getResult(), self.getError())
def onError(self, reply: "QNetworkReply", error: Optional["QNetworkReply.NetworkError"]):
Logger.error(f"Failed to upload material archive: {error}")
self.setResult(self.Result.FAILED)
self.uploadCompleted.emit(self.getResult())
self.setError(UploadMaterialsError(error))
self.uploadCompleted.emit(self.getResult(), self.getError())
class UploadMaterialsError(Exception):
"""
Marker class to indicate something went wrong while uploading.
"""
pass

View file

@ -7,7 +7,7 @@ from typing import Optional, TYPE_CHECKING
import zipfile # To export all materials in a .zip archive.
import cura.CuraApplication # Imported like this to prevent circular imports.
from cura.PrinterOutput.UploadMaterialsJob import UploadMaterialsJob # To export materials to the output printer.
from cura.PrinterOutput.UploadMaterialsJob import UploadMaterialsJob, UploadMaterialsError # To export materials to the output printer.
from cura.Settings.CuraContainerRegistry import CuraContainerRegistry
from UM.i18n import i18nCatalog
from UM.Logger import Logger
@ -155,9 +155,12 @@ class CloudMaterialSync(QObject):
job.uploadCompleted.connect(self.exportUploadCompleted)
job.start()
def exportUploadCompleted(self, job_result: UploadMaterialsJob.Result):
def exportUploadCompleted(self, job_result: UploadMaterialsJob.Result, job_error: Optional[Exception]):
if job_result == UploadMaterialsJob.Result.FAILED:
self.sync_all_dialog.setProperty("syncStatusText", catalog.i18nc("@text", "Something went wrong when sending the materials to the printers."))
if isinstance(job_error, UploadMaterialsError):
self.sync_all_dialog.setProperty("syncStatusText", catalog.i18nc("@text", "Error sending materials to the Digital Factory:") + " " + str(job_error))
else: # Could be "None"
self.sync_all_dialog.setProperty("syncStatusText", catalog.i18nc("@text", "Unknown error."))
self._export_upload_status = "error"
else:
self._export_upload_status = "success"