add error handling
This commit is contained in:
parent
66678c5dee
commit
29c695bbc6
@ -9,6 +9,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<ErrorBar/>
|
||||||
<footer class="footer elevated">
|
<footer class="footer elevated">
|
||||||
<Player />
|
<Player />
|
||||||
</footer>
|
</footer>
|
||||||
@ -27,12 +28,14 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import ErrorBar from "./ErrorBar.vue";
|
||||||
import TopNav from "./TopNav.vue";
|
import TopNav from "./TopNav.vue";
|
||||||
import Sidebar from "./Sidebar.vue";
|
import Sidebar from "./Sidebar.vue";
|
||||||
import Player from "@/player/Player.vue";
|
import Player from "@/player/Player.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
ErrorBar,
|
||||||
TopNav,
|
TopNav,
|
||||||
Sidebar,
|
Sidebar,
|
||||||
Player,
|
Player,
|
||||||
|
28
src/app/ErrorBar.vue
Normal file
28
src/app/ErrorBar.vue
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<template>
|
||||||
|
<b-alert
|
||||||
|
class="fixed-top m-0 rounded-0"
|
||||||
|
variant="danger"
|
||||||
|
:show="error != null"
|
||||||
|
dismissible
|
||||||
|
@dismissed="clearError">
|
||||||
|
<template v-if="error">
|
||||||
|
<strong>{{ error.message }}</strong><br>
|
||||||
|
{{ error.stack }}
|
||||||
|
</template>
|
||||||
|
</b-alert>
|
||||||
|
</template>
|
||||||
|
<script lang="ts">
|
||||||
|
import Vue from "vue";
|
||||||
|
import { mapState, mapMutations } from 'vuex';
|
||||||
|
|
||||||
|
export default Vue.extend({
|
||||||
|
computed: {
|
||||||
|
...mapState(['error'])
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
...mapMutations([
|
||||||
|
'clearError'
|
||||||
|
]),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
@ -33,6 +33,10 @@ connectAudioToStore(store);
|
|||||||
Vue.prototype.$auth = authService;
|
Vue.prototype.$auth = authService;
|
||||||
Vue.prototype.$api = api;
|
Vue.prototype.$api = api;
|
||||||
|
|
||||||
|
Vue.config.errorHandler = (err, vm, info) => {
|
||||||
|
store.commit("setError", err)
|
||||||
|
}
|
||||||
|
|
||||||
new Vue({
|
new Vue({
|
||||||
router,
|
router,
|
||||||
store,
|
store,
|
||||||
|
@ -124,4 +124,7 @@ export function connectAudioToStore(store: Store<any>) {
|
|||||||
audio.onended = (event) => {
|
audio.onended = (event) => {
|
||||||
store.dispatch("player/playNext");
|
store.dispatch("player/playNext");
|
||||||
}
|
}
|
||||||
|
audio.onerror = (event) => {
|
||||||
|
store.commit("setError", audio.error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ interface State {
|
|||||||
isLoggedIn: boolean;
|
isLoggedIn: boolean;
|
||||||
username: null | string;
|
username: null | string;
|
||||||
showMenu: boolean;
|
showMenu: boolean;
|
||||||
errors: any[];
|
error: Error | null;
|
||||||
playlists: any[];
|
playlists: any[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,10 +19,16 @@ const setupRootModule = (authService: AuthService, api: API): Module<State, any>
|
|||||||
isLoggedIn: false,
|
isLoggedIn: false,
|
||||||
username: null,
|
username: null,
|
||||||
showMenu: false,
|
showMenu: false,
|
||||||
errors: [],
|
error: null,
|
||||||
playlists: [],
|
playlists: [],
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
|
setError(state, error) {
|
||||||
|
state.error = error;
|
||||||
|
},
|
||||||
|
clearError(state) {
|
||||||
|
state.error = null;
|
||||||
|
},
|
||||||
setLoginSuccess(state, { username }) {
|
setLoginSuccess(state, { username }) {
|
||||||
state.isLoggedIn = true;
|
state.isLoggedIn = true;
|
||||||
state.username = username;
|
state.username = username;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user