Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎨 [Frontend] Handle LongRunningTask errors better #6485

Merged
merged 8 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ qx.Class.define("osparc.FlashMessenger", {
* @param {osparc.ui.message.FlashMessage} flashMessage FlashMessage element to show.
*/
__showMessage: function(flashMessage) {
if (!flashMessage.getMessage()) {
flashMessage.setMessage(qx.locale.Manager.tr("No message"));
}

this.__messages.remove(flashMessage);
this.__messageContainer.resetDecorator();
this.__messageContainer.add(flashMessage);
Expand All @@ -113,7 +117,8 @@ qx.Class.define("osparc.FlashMessenger", {

let duration = flashMessage.getDuration();
if (duration === null) {
const wordCount = flashMessage.getMessage() ? flashMessage.getMessage().split(" ").length : 20;
const message = flashMessage.getMessage();
const wordCount = message.split(" ").length;
duration = Math.max(5500, wordCount*500); // An average reader takes 300ms to read a word
}
if (duration !== 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1781,8 +1781,8 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
this._updateStudyData(duplicatedStudyData);
});
task.addListener("pollingError", e => {
const errMsg = e.getData();
const msg = this.tr("Something went wrong Duplicating the study<br>") + errMsg;
const err = e.getData();
const msg = this.tr("Something went wrong Duplicating the study<br>") + err.message;
finished(msg, "ERROR");
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,8 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", {
this.reloadResources();
});
task.addListener("pollingError", e => {
const errMsg = e.getData();
const msg = this.tr("Something went wrong Publishing the study<br>") + errMsg;
const err = e.getData();
const msg = this.tr("Something went wrong Publishing the study<br>") + err.message;
finished(msg, "ERROR");
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ qx.Class.define("osparc.data.PollTask", {
return resp.json();
}
const errMsg = qx.locale.Manager.tr("Failed polling status");
this.fireDataEvent("pollingError", errMsg);
throw new Error(errMsg);
const err = new Error(errMsg);
this.fireDataEvent("pollingError", err);
throw err;
})
.then(data => {
if (data === null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ qx.Class.define("osparc.data.PollTasks", {
throw Error("Status missing");
}
})
.catch(errMsg => reject(errMsg));
.catch(err => reject(err));
});
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ qx.Class.define("osparc.study.Utils", {
resolve(resultData);
});
task.addListener("pollingError", e => {
reject("Polling Error");
const err = e.getData();
reject(err);
});
})
.catch(err => reject(err));
Expand Down Expand Up @@ -250,8 +251,8 @@ qx.Class.define("osparc.study.Utils", {
resolve(studyData["uuid"]);
}, this);
task.addListener("pollingError", e => {
const errMsg = e.getData();
reject(errMsg);
const err = e.getData();
reject(err);
}, this);
})
.catch(err => reject(err));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,23 +119,23 @@ qx.Class.define("osparc.ui.message.FlashMessage", {
control = new qx.ui.basic.Image().set({
alignY: "middle"
});
this.getChildControl("message-layout").add(control);
this.getChildControl("message-layout").addAt(control, 0);
break;
case "message":
control = new qx.ui.basic.Label().set({
font: "text-16",
selectable: true,
rich: true
});
this.getChildControl("message-layout").add(control, {
this.getChildControl("message-layout").addAt(control, 1, {
flex: 1
});
break;
case "closebutton":
control = new osparc.ui.basic.IconButton("@MaterialIcons/close/16", () => this.fireEvent("closeMessage")).set({
alignY: "middle"
});
this.getChildControl("message-layout").add(control);
this.getChildControl("message-layout").addAt(control, 2);
break;
}
return control || this.base(arguments, id);
Expand Down
Loading