+37
-11
lines changedFilter options
+37
-11
lines changed Original file line number Diff line number Diff line change
@@ -6,16 +6,24 @@ import { inBrowser } from './env'
6
6
7
7
export function handleError (err: Error, vm: any, info: string) {
8
8
if (config.errorHandler) {
9
-
config.errorHandler.call(null, err, vm, info)
10
-
} else {
11
-
if (process.env.NODE_ENV !== 'production') {
12
-
warn(`Error in ${info}: "${err.toString()}"`, vm)
13
-
}
14
-
/* istanbul ignore else */
15
-
if (inBrowser && typeof console !== 'undefined') {
16
-
console.error(err)
17
-
} else {
18
-
throw err
9
+
try {
10
+
config.errorHandler.call(null, err, vm, info)
11
+
return
12
+
} catch (e) {
13
+
logError(e, null, 'errorHandler')
19
14
}
20
15
}
16
+
logError(err, vm, info)
17
+
}
18
+
19
+
function logError (err, vm, info) {
20
+
if (process.env.NODE_ENV !== 'production') {
21
+
warn(`Error in ${info}: "${err.toString()}"`, vm)
22
+
}
23
+
/* istanbul ignore else */
24
+
if (inBrowser && typeof console !== 'undefined') {
25
+
console.error(err)
26
+
} else {
27
+
throw err
28
+
}
21
29
}
Original file line number Diff line number Diff line change
@@ -92,7 +92,7 @@ describe('Error handling', () => {
92
92
}).then(done)
93
93
})
94
94
95
-
it('config.errorHandler should capture errors', done => {
95
+
it('config.errorHandler should capture render errors', done => {
96
96
const spy = Vue.config.errorHandler = jasmine.createSpy('errorHandler')
97
97
const vm = createTestInstance(components.render)
98
98
@@ -124,6 +124,24 @@ describe('Error handling', () => {
124
124
})
125
125
})
126
126
})
127
+
128
+
it('should recover from errors thrown in errorHandler itself', () => {
129
+
Vue.config.errorHandler = () => {
130
+
throw new Error('error in errorHandler ¯\\_(ツ)_/¯')
131
+
}
132
+
const vm = new Vue({
133
+
render (h) {
134
+
throw new Error('error in render')
135
+
},
136
+
renderError (h, err) {
137
+
return h('div', err.toString())
138
+
}
139
+
}).$mount()
140
+
expect('error in errorHandler').toHaveBeenWarned()
141
+
expect('error in render').toHaveBeenWarned()
142
+
expect(vm.$el.textContent).toContain('error in render')
143
+
Vue.config.errorHandler = null
144
+
})
127
145
})
128
146
129
147
function createErrorTestComponents () {
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4