Display import errors to user (#27147)

* Display import errors to user

* Refactored

* Refactored

* Refactored

* Fixed quality

* Fixed quality

* Refactored code

* Fixed message

* Refactored code
This commit is contained in:
AsadAzam
2021-04-02 18:53:39 +05:00
committed by GitHub
parent c64d6ab1f0
commit c4da6c1fe4
4 changed files with 41 additions and 12 deletions

View File

@@ -240,7 +240,7 @@ define(
*
* @param {int} [stage=0] Starting stage.
*/
pollStatus: function(stage) {
pollStatus: function(stage, message) {
if (current.state !== STATE.IN_PROGRESS) {
return;
}
@@ -250,13 +250,13 @@ define(
if (current.stage === STAGE.SUCCESS) {
success();
} else if (current.stage < STAGE.UPLOADING) { // Failed
error(gettext('Error importing course'));
error(message || gettext('Error importing course'));
} else { // In progress
updateFeedbackList();
$.getJSON(file.url, function(data) {
timeout.id = setTimeout(function() {
this.pollStatus(data.ImportStatus);
this.pollStatus(data.ImportStatus, data.Message);
}.bind(this), timeout.delay);
}.bind(this));
}
@@ -292,7 +292,7 @@ define(
if (current.stage !== STAGE.UPLOADING) {
current.state = STATE.IN_PROGRESS;
this.pollStatus(current.stage);
this.pollStatus(current.stage, data.Message);
} else {
// An import in the upload stage cannot be resumed
error(gettext('There was an error with the upload'));