mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-15 11:25:53 +08:00
Add missing error-handling.
There was error handling for the url-request, but not for handling the subsequent resolution.
This commit is contained in:
parent
43a055cfd5
commit
b0f175bd5a
@ -1895,7 +1895,14 @@ class CuraApplication(QtApplication):
|
|||||||
query = QUrlQuery(url.query())
|
query = QUrlQuery(url.query())
|
||||||
model_url = QUrl(query.queryItemValue("file", options=QUrl.ComponentFormattingOption.FullyDecoded))
|
model_url = QUrl(query.queryItemValue("file", options=QUrl.ComponentFormattingOption.FullyDecoded))
|
||||||
|
|
||||||
|
def on_error(*args, **kwargs):
|
||||||
|
Logger.warning(f"Could not download file from {model_url.url()}")
|
||||||
|
Message(f"Could not download file: {str(model_url.url())}",
|
||||||
|
title= "Loading Model failed",
|
||||||
|
message_type=Message.MessageType.ERROR).show()
|
||||||
|
|
||||||
def on_finish(response):
|
def on_finish(response):
|
||||||
|
try:
|
||||||
content_disposition_header_key = QByteArray("content-disposition".encode())
|
content_disposition_header_key = QByteArray("content-disposition".encode())
|
||||||
|
|
||||||
filename = model_url.path().split("/")[-1] + ".stl"
|
filename = model_url.path().split("/")[-1] + ".stl"
|
||||||
@ -1918,13 +1925,9 @@ class CuraApplication(QtApplication):
|
|||||||
f.write(response.readAll())
|
f.write(response.readAll())
|
||||||
|
|
||||||
self.readLocalFile(QUrl.fromLocalFile(tmp.name), add_to_recent_files=False)
|
self.readLocalFile(QUrl.fromLocalFile(tmp.name), add_to_recent_files=False)
|
||||||
|
except Exception as ex:
|
||||||
def on_error(*args, **kwargs):
|
Logger.warning(f"Exception {str(ex)}")
|
||||||
Logger.log("w", "Could not download file from {0}".format(model_url.url()))
|
on_error()
|
||||||
Message("Could not download file: " + str(model_url.url()),
|
|
||||||
title= "Loading Model failed",
|
|
||||||
message_type=Message.MessageType.ERROR).show()
|
|
||||||
return
|
|
||||||
|
|
||||||
self.getHttpRequestManager().get(
|
self.getHttpRequestManager().get(
|
||||||
model_url.url(),
|
model_url.url(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user