From 3e7f5ab02fbbac5c0586a4565f1c9e1ed5d785e3 Mon Sep 17 00:00:00 2001 From: Helios Date: Fri, 2 Oct 2020 13:23:51 +0800 Subject: [PATCH 1/3] fix(runtime-core): consist with vue2's error capturing behavior --- packages/runtime-core/src/errorHandling.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 } } From faaed49be493a20700cb33411e3bd35d22113421 Mon Sep 17 00:00:00 2001 From: Helios Date: Fri, 2 Oct 2020 13:46:23 +0800 Subject: [PATCH 2/3] test(runtime-core): modify tests for errorCaptured --- .../__tests__/errorHandling.spec.ts | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) 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, { From 4778b65b65c9f23766d55a7ce88be1a623cf5bf0 Mon Sep 17 00:00:00 2001 From: Helios Date: Fri, 2 Oct 2020 13:53:32 +0800 Subject: [PATCH 3/3] test(runtime-core): modify tests for errorCaptured --- packages/runtime-core/__tests__/components/Suspense.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 () =>