Skip to content

Commit

Permalink
Revise CoachToolsModule's promise handling to keep things moving alon…
Browse files Browse the repository at this point in the history
…g even if an error occurs mid-navigation (for example, like in QuizSummary's beforeRouteEnter)
  • Loading branch information
nucleogenesis committed Nov 27, 2024
1 parent 37c2cc5 commit 3eaa320
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
13 changes: 10 additions & 3 deletions kolibri/plugins/coach/assets/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,16 @@ class CoachToolsModule extends KolibriApp {
}

if (promises.length > 0) {
Promise.all(promises).then(next, error => {
this.store.dispatch('handleApiError', { error });
});
Promise.all(promises)
.catch(error => {
this.store.dispatch('handleApiError', { error });
})
.catch(() => {
// We catch here because `handleApiError` throws the error back again, in this case,
// we just want things to keep moving so that the AuthMessage shows as expected
next();
})
.then(next);
} else {
next();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,14 @@
},
// @public
setError(error) {
this.$store.dispatch('handleApiError', { error });
this.loading = false;
this.$store.dispatch('notLoading');
try {
this.$store.dispatch('handleApiError', { error });
this.loading = false;
this.$store.dispatch('notLoading');
} catch (e) {
// nothing to do here, just catching the error to avoid
// unhandled errors in the dispatch to handleApiError
}
},
setCurrentAction(action) {
if (action === 'EDIT_DETAILS') {
Expand Down

0 comments on commit 3eaa320

Please sign in to comment.