fix(vue-app): Fix default error handler in production

This commit is contained in:
Sébastien Chopin 2018-12-19 19:39:38 +01:00
parent 5568d4aa9a
commit 96892c5341

View File

@ -31,7 +31,7 @@ const NUXT = window.<%= globals.context %> || {}
Object.assign(Vue.config, <%= serialize(vue.config) %>)<%= isTest ? '// eslint-disable-line' : '' %>
<% if (debug || mode === 'spa') { %>
<% if (debug) { %>
// Setup global Vue error handler
if (!Vue.config.$nuxt) {
const defaultErrorHandler = Vue.config.errorHandler
@ -70,13 +70,14 @@ if (!Vue.config.$nuxt) {
}
Vue.config.$nuxt.<%= globals.nuxt %> = true
<% } %>
const errorHandler = Vue.config.errorHandler || console.error
// Create and mount App
createApp()
.then(mountApp)
.catch((err) => {
err.message = '[nuxt] Error while mounting app: ' + err.message
Vue.config.errorHandler(err)
errorHandler(err)
})
function componentOption(component, key, ...args) {
@ -685,7 +686,7 @@ async function mountApp(__app) {
// Push the path and then mount app
router.push(path, () => mount(), (err) => {
if (!err) return mount()
Vue.config.errorHandler(err)
errorHandler(err)
})
})
}