Skip to content

Commit 4d20ac8

Browse files
authored
fix(runtime-core): make errorCaptured return value handling consistent with Vue 2 (#2289)
fix #2267
1 parent ea1f87e commit 4d20ac8

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

packages/runtime-core/__tests__/components/Suspense.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ describe('Suspense', () => {
609609
err instanceof Error
610610
? err.message
611611
: `A non-Error value thrown: ${err}`
612-
return true
612+
return false
613613
})
614614

615615
return () =>

packages/runtime-core/__tests__/errorHandling.spec.ts

+15-15
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('error handling', () => {
2020
setup() {
2121
onErrorCaptured((err, instance, info) => {
2222
fn(err, info, 'root')
23-
return true
23+
return false
2424
})
2525
return () => h(Child)
2626
}
@@ -58,7 +58,7 @@ describe('error handling', () => {
5858
setup() {
5959
onErrorCaptured((err, instance, info) => {
6060
fn(err, info, 'root')
61-
return true
61+
return false
6262
})
6363
return () => h(Child)
6464
}
@@ -68,7 +68,7 @@ describe('error handling', () => {
6868
setup() {
6969
onErrorCaptured((err, instance, info) => {
7070
fn(err, info, 'child')
71-
return true
71+
return false
7272
})
7373
return () => h(GrandChild)
7474
}
@@ -96,7 +96,7 @@ describe('error handling', () => {
9696
setup() {
9797
onErrorCaptured((err, instance, info) => {
9898
fn(err, info)
99-
return true
99+
return false
100100
})
101101
return () => h(Child)
102102
}
@@ -126,7 +126,7 @@ describe('error handling', () => {
126126
setup() {
127127
onErrorCaptured((err, instance, info) => {
128128
fn(err, info)
129-
return true
129+
return false
130130
})
131131
return () => h(Child)
132132
}
@@ -164,7 +164,7 @@ describe('error handling', () => {
164164
setup() {
165165
onErrorCaptured((err, instance, info) => {
166166
fn(err, info)
167-
return true
167+
return false
168168
})
169169
return () => h(Child)
170170
}
@@ -189,7 +189,7 @@ describe('error handling', () => {
189189
setup() {
190190
onErrorCaptured((err, instance, info) => {
191191
fn(err, info)
192-
return true
192+
return false
193193
})
194194
return () => h(Child)
195195
}
@@ -218,7 +218,7 @@ describe('error handling', () => {
218218
setup() {
219219
onErrorCaptured((err, instance, info) => {
220220
fn(err, info)
221-
return true
221+
return false
222222
})
223223
return () => h(Child)
224224
}
@@ -238,7 +238,7 @@ describe('error handling', () => {
238238
setup() {
239239
onErrorCaptured((err, instance, info) => {
240240
fn(err, info)
241-
return true
241+
return false
242242
})
243243
return () => h(Child)
244244
}
@@ -265,7 +265,7 @@ describe('error handling', () => {
265265
setup() {
266266
onErrorCaptured((err, instance, info) => {
267267
fn(err, info)
268-
return true
268+
return false
269269
})
270270
return () => h(Child)
271271
}
@@ -295,7 +295,7 @@ describe('error handling', () => {
295295
setup() {
296296
onErrorCaptured((err, instance, info) => {
297297
fn(err, info)
298-
return true
298+
return false
299299
})
300300
return () => h(Child)
301301
}
@@ -330,7 +330,7 @@ describe('error handling', () => {
330330
setup() {
331331
onErrorCaptured((err, instance, info) => {
332332
fn(err, info)
333-
return true
333+
return false
334334
})
335335
return () => h(Child)
336336
}
@@ -363,7 +363,7 @@ describe('error handling', () => {
363363
setup() {
364364
onErrorCaptured((err, instance, info) => {
365365
fn(err, info)
366-
return true
366+
return false
367367
})
368368
return () =>
369369
h(Child, {
@@ -393,7 +393,7 @@ describe('error handling', () => {
393393
setup() {
394394
onErrorCaptured((err, instance, info) => {
395395
fn(err, info)
396-
return true
396+
return false
397397
})
398398
return () =>
399399
h(Child, {
@@ -431,7 +431,7 @@ describe('error handling', () => {
431431
setup() {
432432
onErrorCaptured((err, instance, info) => {
433433
fn(err, info)
434-
return true
434+
return false
435435
})
436436
return () =>
437437
h(Child, {

packages/runtime-core/src/errorHandling.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ export function handleError(
113113
const errorCapturedHooks = cur.ec
114114
if (errorCapturedHooks) {
115115
for (let i = 0; i < errorCapturedHooks.length; i++) {
116-
if (errorCapturedHooks[i](err, exposedInstance, errorInfo)) {
116+
if (
117+
errorCapturedHooks[i](err, exposedInstance, errorInfo) === false
118+
) {
117119
return
118120
}
119121
}

0 commit comments

Comments
 (0)