From 4d20ac8173f84c87288255dcc03c62a6ee862a23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=B4=9C=C9=B4=D0=B2=CA=8F=D1=82=E1=B4=87?= Date: Tue, 6 Oct 2020 05:37:26 +0800 Subject: [PATCH] fix(runtime-core): make errorCaptured return value handling consistent with Vue 2 (#2289) fix #2267 --- .../__tests__/components/Suspense.spec.ts | 2 +- .../__tests__/errorHandling.spec.ts | 30 +++++++++---------- packages/runtime-core/src/errorHandling.ts | 4 ++- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/packages/runtime-core/__tests__/components/Suspense.spec.ts b/packages/runtime-core/__tests__/components/Suspense.spec.ts index c6ab0f3fa32..5602b4a7f14 100644 --- a/packages/runtime-core/__tests__/components/Suspense.spec.ts +++ b/packages/runtime-core/__tests__/components/Suspense.spec.ts @@ -609,7 +609,7 @@ describe('Suspense', () => { err instanceof Error ? err.message : `A non-Error value thrown: ${err}` - return true + return false }) return () => diff --git a/packages/runtime-core/__tests__/errorHandling.spec.ts b/packages/runtime-core/__tests__/errorHandling.spec.ts index 47d6c489262..eed67913633 100644 --- a/packages/runtime-core/__tests__/errorHandling.spec.ts +++ b/packages/runtime-core/__tests__/errorHandling.spec.ts @@ -20,7 +20,7 @@ describe('error handling', () => { setup() { onErrorCaptured((err, instance, info) => { fn(err, info, 'root') - return true + return false }) return () => h(Child) } @@ -58,7 +58,7 @@ describe('error handling', () => { setup() { onErrorCaptured((err, instance, info) => { fn(err, info, 'root') - return true + return false }) return () => h(Child) } @@ -68,7 +68,7 @@ describe('error handling', () => { setup() { onErrorCaptured((err, instance, info) => { fn(err, info, 'child') - return true + return false }) return () => h(GrandChild) } @@ -96,7 +96,7 @@ describe('error handling', () => { setup() { onErrorCaptured((err, instance, info) => { fn(err, info) - return true + return false }) return () => h(Child) } @@ -126,7 +126,7 @@ describe('error handling', () => { setup() { onErrorCaptured((err, instance, info) => { fn(err, info) - return true + return false }) return () => h(Child) } @@ -164,7 +164,7 @@ describe('error handling', () => { setup() { onErrorCaptured((err, instance, info) => { fn(err, info) - return true + return false }) return () => h(Child) } @@ -189,7 +189,7 @@ describe('error handling', () => { setup() { onErrorCaptured((err, instance, info) => { fn(err, info) - return true + return false }) return () => h(Child) } @@ -218,7 +218,7 @@ describe('error handling', () => { setup() { onErrorCaptured((err, instance, info) => { fn(err, info) - return true + return false }) return () => h(Child) } @@ -238,7 +238,7 @@ describe('error handling', () => { setup() { onErrorCaptured((err, instance, info) => { fn(err, info) - return true + return false }) return () => h(Child) } @@ -265,7 +265,7 @@ describe('error handling', () => { setup() { onErrorCaptured((err, instance, info) => { fn(err, info) - return true + return false }) return () => h(Child) } @@ -295,7 +295,7 @@ describe('error handling', () => { setup() { onErrorCaptured((err, instance, info) => { fn(err, info) - return true + return false }) return () => h(Child) } @@ -330,7 +330,7 @@ describe('error handling', () => { setup() { onErrorCaptured((err, instance, info) => { fn(err, info) - return true + return false }) return () => h(Child) } @@ -363,7 +363,7 @@ describe('error handling', () => { setup() { onErrorCaptured((err, instance, info) => { fn(err, info) - return true + return false }) return () => h(Child, { @@ -393,7 +393,7 @@ describe('error handling', () => { setup() { onErrorCaptured((err, instance, info) => { fn(err, info) - return true + return false }) return () => h(Child, { @@ -431,7 +431,7 @@ describe('error handling', () => { setup() { onErrorCaptured((err, instance, info) => { fn(err, info) - return true + return false }) return () => h(Child, { diff --git a/packages/runtime-core/src/errorHandling.ts b/packages/runtime-core/src/errorHandling.ts index 1823f6b729c..fedb0f83f01 100644 --- a/packages/runtime-core/src/errorHandling.ts +++ b/packages/runtime-core/src/errorHandling.ts @@ -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 } }