diff --git a/src/app/App.vue b/src/app/App.vue index 0e90fb8..90fb2d4 100644 --- a/src/app/App.vue +++ b/src/app/App.vue @@ -9,6 +9,7 @@ + @@ -27,12 +28,14 @@ } \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index 2d0b7d4..13b9433 100644 --- a/src/main.ts +++ b/src/main.ts @@ -33,6 +33,10 @@ connectAudioToStore(store); Vue.prototype.$auth = authService; Vue.prototype.$api = api; +Vue.config.errorHandler = (err, vm, info) => { + store.commit("setError", err) +} + new Vue({ router, store, diff --git a/src/player/store.ts b/src/player/store.ts index abfdbba..e4f7cea 100644 --- a/src/player/store.ts +++ b/src/player/store.ts @@ -124,4 +124,7 @@ export function connectAudioToStore(store: Store) { audio.onended = (event) => { store.dispatch("player/playNext"); } + audio.onerror = (event) => { + store.commit("setError", audio.error); + } } diff --git a/src/shared/store.ts b/src/shared/store.ts index ede4535..ff2b926 100644 --- a/src/shared/store.ts +++ b/src/shared/store.ts @@ -10,7 +10,7 @@ interface State { isLoggedIn: boolean; username: null | string; showMenu: boolean; - errors: any[]; + error: Error | null; playlists: any[]; } @@ -19,10 +19,16 @@ const setupRootModule = (authService: AuthService, api: API): Module isLoggedIn: false, username: null, showMenu: false, - errors: [], + error: null, playlists: [], }, mutations: { + setError(state, error) { + state.error = error; + }, + clearError(state) { + state.error = null; + }, setLoginSuccess(state, { username }) { state.isLoggedIn = true; state.username = username;