Skip to content

Commit

Permalink
fix(runtime-core): make errorCaptured return value handling consisten…
Browse files Browse the repository at this point in the history
…t with Vue 2 (#2289)

fix #2267
  • Loading branch information
unbyte authored Oct 5, 2020
1 parent ea1f87e commit 4d20ac8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ describe('Suspense', () => {
err instanceof Error
? err.message
: `A non-Error value thrown: ${err}`
return true
return false
})

return () =>
Expand Down
30 changes: 15 additions & 15 deletions packages/runtime-core/__tests__/errorHandling.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('error handling', () => {
setup() {
onErrorCaptured((err, instance, info) => {
fn(err, info, 'root')
return true
return false
})
return () => h(Child)
}
Expand Down Expand Up @@ -58,7 +58,7 @@ describe('error handling', () => {
setup() {
onErrorCaptured((err, instance, info) => {
fn(err, info, 'root')
return true
return false
})
return () => h(Child)
}
Expand All @@ -68,7 +68,7 @@ describe('error handling', () => {
setup() {
onErrorCaptured((err, instance, info) => {
fn(err, info, 'child')
return true
return false
})
return () => h(GrandChild)
}
Expand Down Expand Up @@ -96,7 +96,7 @@ describe('error handling', () => {
setup() {
onErrorCaptured((err, instance, info) => {
fn(err, info)
return true
return false
})
return () => h(Child)
}
Expand Down Expand Up @@ -126,7 +126,7 @@ describe('error handling', () => {
setup() {
onErrorCaptured((err, instance, info) => {
fn(err, info)
return true
return false
})
return () => h(Child)
}
Expand Down Expand Up @@ -164,7 +164,7 @@ describe('error handling', () => {
setup() {
onErrorCaptured((err, instance, info) => {
fn(err, info)
return true
return false
})
return () => h(Child)
}
Expand All @@ -189,7 +189,7 @@ describe('error handling', () => {
setup() {
onErrorCaptured((err, instance, info) => {
fn(err, info)
return true
return false
})
return () => h(Child)
}
Expand Down Expand Up @@ -218,7 +218,7 @@ describe('error handling', () => {
setup() {
onErrorCaptured((err, instance, info) => {
fn(err, info)
return true
return false
})
return () => h(Child)
}
Expand All @@ -238,7 +238,7 @@ describe('error handling', () => {
setup() {
onErrorCaptured((err, instance, info) => {
fn(err, info)
return true
return false
})
return () => h(Child)
}
Expand All @@ -265,7 +265,7 @@ describe('error handling', () => {
setup() {
onErrorCaptured((err, instance, info) => {
fn(err, info)
return true
return false
})
return () => h(Child)
}
Expand Down Expand Up @@ -295,7 +295,7 @@ describe('error handling', () => {
setup() {
onErrorCaptured((err, instance, info) => {
fn(err, info)
return true
return false
})
return () => h(Child)
}
Expand Down Expand Up @@ -330,7 +330,7 @@ describe('error handling', () => {
setup() {
onErrorCaptured((err, instance, info) => {
fn(err, info)
return true
return false
})
return () => h(Child)
}
Expand Down Expand Up @@ -363,7 +363,7 @@ describe('error handling', () => {
setup() {
onErrorCaptured((err, instance, info) => {
fn(err, info)
return true
return false
})
return () =>
h(Child, {
Expand Down Expand Up @@ -393,7 +393,7 @@ describe('error handling', () => {
setup() {
onErrorCaptured((err, instance, info) => {
fn(err, info)
return true
return false
})
return () =>
h(Child, {
Expand Down Expand Up @@ -431,7 +431,7 @@ describe('error handling', () => {
setup() {
onErrorCaptured((err, instance, info) => {
fn(err, info)
return true
return false
})
return () =>
h(Child, {
Expand Down
4 changes: 3 additions & 1 deletion packages/runtime-core/src/errorHandling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ export function handleError(
const errorCapturedHooks = cur.ec
if (errorCapturedHooks) {
for (let i = 0; i < errorCapturedHooks.length; i++) {
if (errorCapturedHooks[i](err, exposedInstance, errorInfo)) {
if (
errorCapturedHooks[i](err, exposedInstance, errorInfo) === false
) {
return
}
}
Expand Down

0 comments on commit 4d20ac8

Please sign in to comment.