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:
parent
feedda87ed
commit
3d33218072
1 changed files with 25 additions and 25 deletions
|
|
@ -175,7 +175,30 @@ 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);
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
// Do something with the final response
|
||||||
|
|
||||||
|
this.$emit("response", response);
|
||||||
|
this.$emit("finished");
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
if (!error) {
|
||||||
|
error = Error("Unknown error");
|
||||||
|
}
|
||||||
|
this.$emit("error", error);
|
||||||
|
this.$emit("finished");
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
// Reset taskRunning and taskId
|
||||||
|
this.taskRunning = false;
|
||||||
|
this.taskStarted = false;
|
||||||
|
this.taskId = null;
|
||||||
|
// Update the form data if we're self-updating
|
||||||
|
if (this.selfUpdate) {
|
||||||
|
this.getFormData();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -187,30 +210,7 @@ export default {
|
||||||
// Start the store polling TaskId for success
|
// Start the store polling TaskId for success
|
||||||
this.taskRunning = true;
|
this.taskRunning = true;
|
||||||
this.$emit("taskRunning", this.taskId);
|
this.$emit("taskRunning", this.taskId);
|
||||||
this.pollTask(this.taskId, this.pollInterval)
|
return this.pollTask(this.taskId, this.pollInterval);
|
||||||
.then(response => {
|
|
||||||
// Do something with the final response
|
|
||||||
|
|
||||||
this.$emit("response", response);
|
|
||||||
this.$emit("finished");
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
if (!error) {
|
|
||||||
error = Error("Unknown error");
|
|
||||||
}
|
|
||||||
this.$emit("error", error);
|
|
||||||
this.$emit("finished");
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
// Reset taskRunning and taskId
|
|
||||||
this.taskRunning = false;
|
|
||||||
this.taskStarted = false;
|
|
||||||
this.taskId = null;
|
|
||||||
// Update the form data if we're self-updating
|
|
||||||
if (this.selfUpdate) {
|
|
||||||
this.getFormData();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue