From 3eaa320f8548f163b663338e930670d4e1bca4dd Mon Sep 17 00:00:00 2001 From: Jacob Pierce Date: Wed, 27 Nov 2024 11:36:10 -0800 Subject: [PATCH] Revise CoachToolsModule's promise handling to keep things moving along even if an error occurs mid-navigation (for example, like in QuizSummary's beforeRouteEnter) --- kolibri/plugins/coach/assets/src/app.js | 13 ++++++++++--- .../src/views/quizzes/QuizSummaryPage/index.vue | 11 ++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/kolibri/plugins/coach/assets/src/app.js b/kolibri/plugins/coach/assets/src/app.js index fc0d1f84f4e..09617c3991d 100644 --- a/kolibri/plugins/coach/assets/src/app.js +++ b/kolibri/plugins/coach/assets/src/app.js @@ -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(); } diff --git a/kolibri/plugins/coach/assets/src/views/quizzes/QuizSummaryPage/index.vue b/kolibri/plugins/coach/assets/src/views/quizzes/QuizSummaryPage/index.vue index bfe3a541018..338f73f2704 100644 --- a/kolibri/plugins/coach/assets/src/views/quizzes/QuizSummaryPage/index.vue +++ b/kolibri/plugins/coach/assets/src/views/quizzes/QuizSummaryPage/index.vue @@ -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') {