mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-25 15:44:04 -06:00
Always provide error message if upload failed
Contributes to issue CURA-8609.
This commit is contained in:
parent
4ccd4caaad
commit
a6b6b075ea
1 changed files with 8 additions and 2 deletions
|
@ -9,12 +9,15 @@ import enum
|
||||||
import cura.CuraApplication # Imported like this to prevent circular imports.
|
import cura.CuraApplication # Imported like this to prevent circular imports.
|
||||||
from cura.UltimakerCloud import UltimakerCloudConstants # To know where the API is.
|
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 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.Job import Job
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
from UM.Signal import Signal
|
from UM.Signal import Signal
|
||||||
from UM.TaskManagement.HttpRequestManager import HttpRequestManager # To call the API.
|
from UM.TaskManagement.HttpRequestManager import HttpRequestManager # To call the API.
|
||||||
from UM.TaskManagement.HttpRequestScope import JsonDecoratorScope
|
from UM.TaskManagement.HttpRequestScope import JsonDecoratorScope
|
||||||
|
|
||||||
|
catalog = i18nCatalog("cura")
|
||||||
|
|
||||||
from typing import Optional, TYPE_CHECKING
|
from typing import Optional, TYPE_CHECKING
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from PyQt5.QtNetwork import QNetworkReply
|
from PyQt5.QtNetwork import QNetworkReply
|
||||||
|
@ -66,14 +69,17 @@ class UploadMaterialsJob(Job):
|
||||||
response_data = HttpRequestManager.readJSON(reply)
|
response_data = HttpRequestManager.readJSON(reply)
|
||||||
if response_data is None:
|
if response_data is None:
|
||||||
Logger.error(f"Invalid response to material upload request. Could not parse JSON data.")
|
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)
|
self.setResult(self.Result.FAILED)
|
||||||
return
|
return
|
||||||
if "upload_url" not in response_data:
|
if "upload_url" not in response_data:
|
||||||
Logger.error(f"Invalid response to material upload request: Missing 'upload_url' field to upload archive to.")
|
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)
|
self.setResult(self.Result.FAILED)
|
||||||
return
|
return
|
||||||
if "material_profile_id" not in response_data:
|
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.")
|
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)
|
self.setResult(self.Result.FAILED)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -92,7 +98,7 @@ class UploadMaterialsJob(Job):
|
||||||
def onUploadCompleted(self, reply: "QNetworkReply", error: Optional["QNetworkReply.NetworkError"]):
|
def onUploadCompleted(self, reply: "QNetworkReply", error: Optional["QNetworkReply.NetworkError"]):
|
||||||
if error is not None:
|
if error is not None:
|
||||||
Logger.error(f"Failed to upload material archive: {error}")
|
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)
|
self.setResult(self.Result.FAILED)
|
||||||
else:
|
else:
|
||||||
self.setResult(self.Result.SUCCESS)
|
self.setResult(self.Result.SUCCESS)
|
||||||
|
@ -101,7 +107,7 @@ class UploadMaterialsJob(Job):
|
||||||
def onError(self, reply: "QNetworkReply", error: Optional["QNetworkReply.NetworkError"]):
|
def onError(self, reply: "QNetworkReply", error: Optional["QNetworkReply.NetworkError"]):
|
||||||
Logger.error(f"Failed to upload material archive: {error}")
|
Logger.error(f"Failed to upload material archive: {error}")
|
||||||
self.setResult(self.Result.FAILED)
|
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())
|
self.uploadCompleted.emit(self.getResult(), self.getError())
|
||||||
|
|
||||||
class UploadMaterialsError(Exception):
|
class UploadMaterialsError(Exception):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue