Move error handling for taskSubmitter

taskSubmitter ended up in a confused state if the initial POST request
encountered an error.
I've updated `startPolling` to return a Promise, and moved the
error handling code to the top level.

This doesn't change anything for the case where we get a non-error
response to the POST request, but means that e.g. 400 errors
get caught and displayed properly.
This commit is contained in:
Richard 2021-08-26 23:12:47 +01:00
parent feedda87ed
commit 3d33218072

View file

@ -175,19 +175,8 @@ export default {
// Get the returned Task ID // Get the returned Task ID
.then(response => { .then(response => {
// Start the store polling TaskId for success // Start the store polling TaskId for success
this.startPolling(response.data.id, response.data.href); return this.startPolling(response.data.id, response.data.href);
}); })
},
startPolling: function(taskId, taskUrl) {
if (this.taskRunning != true) {
// Starts polling an existing Action task
this.taskId = taskId;
this.taskUrl = taskUrl;
// Start the store polling TaskId for success
this.taskRunning = true;
this.$emit("taskRunning", this.taskId);
this.pollTask(this.taskId, this.pollInterval)
.then(response => { .then(response => {
// Do something with the final response // Do something with the final response
@ -211,6 +200,17 @@ export default {
this.getFormData(); this.getFormData();
} }
}); });
},
startPolling: function(taskId, taskUrl) {
if (this.taskRunning != true) {
// Starts polling an existing Action task
this.taskId = taskId;
this.taskUrl = taskUrl;
// Start the store polling TaskId for success
this.taskRunning = true;
this.$emit("taskRunning", this.taskId);
return this.pollTask(this.taskId, this.pollInterval);
} }
}, },