Migrate core error handling from Vuex to a useAppError composable
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Overview
Complexity: High Target branch: develop
Context
The core Vuex module manages error state via handleError, handleApiError, and clearError actions, plus the CORE_SET_ERROR mutation and state.core.error. This is the most widely consumed piece of core Vuex state — ~95 files dispatch these actions across all plugins and core packages.
The error state is read by AppError.vue and NotificationsRoot/index.vue (both in the kolibri package) to render full-page error displays. It is written from plugin route handlers, composables, and components across the entire codebase.
Because the readers are specialized error-display components (not generic page wrappers), a shared composable is the right pattern — unlike loading state which is being moved to props.
Note: handleApiError currently re-throws the error after setting state, which has caused issues in route guards (see #11722 comment from @nucleogenesis). Reconsidering the throw behavior is out of scope for this issue but worth being aware of during implementation.
The Change
Create a useAppError composable in packages/kolibri/composables/ that exposes:
- A reactive
errorref handleError(errorString)— sets error statehandleApiError({ error, reloadOnReconnect })— handles API errors with disconnection detectionclearError()— clears error state
Update AppError.vue and NotificationsRoot to use the composable instead of mapState/mapActions. Update all ~95 consumer files across plugins and packages to import and call the composable functions instead of dispatching Vuex actions.
Remove the CORE_SET_ERROR mutation and the three actions from the core Vuex module.
Out of Scope
- Changing the
handleApiErrorre-throw behavior - Plugin-level Vuex module migration
Acceptance Criteria
- [ ]
useAppErrorcomposable exists inpackages/kolibri/composables/ - [ ]
AppError.vueandNotificationsRootuse the composable, not Vuex - [ ] All consumer files updated to import from the composable instead of dispatching Vuex actions
- [ ]
handleError,handleApiError,clearErroractions removed from core Vuex module - [ ]
CORE_SET_ERRORmutation removed from core Vuex module - [ ] No remaining
store.dispatch('handleError'...),store.dispatch('handleApiError'...),store.dispatch('clearError'), ormapActions(['clearError'])references - [ ] Existing test coverage updated
AI usage
This issue was drafted with Claude Code (Opus). The consumer inventory was produced by grepping the codebase. The composable approach was discussed and agreed upon with the maintainer — a shared composable fits because the error readers are specialized components, unlike loading which moved to props.
Watching for resolution on behalf of learningequality/kolibri#14514.