Catch errors in vue app and emit message if provided by the response
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
@@ -53,6 +53,14 @@ Vue.directive('focus', {
|
||||
},
|
||||
})
|
||||
|
||||
Vue.config.errorHandler = (err, vm, info) => {
|
||||
if (err.response && err.response.data.message) {
|
||||
const errorMessage = t('deck', 'Something went wrong')
|
||||
OCP.Toast.error(`${errorMessage}: ${err.response.data.status} ${err.response.data.message}`)
|
||||
}
|
||||
throw err
|
||||
}
|
||||
|
||||
/* eslint-disable-next-line no-new */
|
||||
new Vue({
|
||||
el: '#content',
|
||||
|
||||
Reference in New Issue
Block a user