From 6dac3dbe441302cebb945b675f78f8e7247e2a97 Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 6 Oct 2017 16:35:27 -0400 Subject: [PATCH] feat: rename catchError -> errorCaptured --- src/core/util/error.js | 6 +++--- .../{catchError.spec.js => errorCaptured.spec.js} | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) rename test/unit/features/options/{catchError.spec.js => errorCaptured.spec.js} (90%) diff --git a/src/core/util/error.js b/src/core/util/error.js index 9b87f89e46..a454158da7 100644 --- a/src/core/util/error.js +++ b/src/core/util/error.js @@ -8,12 +8,12 @@ export function handleError (err: Error, vm: any, info: string) { if (vm) { let cur = vm while ((cur = cur.$parent)) { - if (cur.$options.catchError) { + if (cur.$options.errorCaptured) { try { - const propagate = cur.$options.catchError.call(cur, err, vm, info) + const propagate = cur.$options.errorCaptured.call(cur, err, vm, info) if (!propagate) return } catch (e) { - globalHandleError(e, cur, 'catchError') + globalHandleError(e, cur, 'errorCaptured hook') } } } diff --git a/test/unit/features/options/catchError.spec.js b/test/unit/features/options/errorCaptured.spec.js similarity index 90% rename from test/unit/features/options/catchError.spec.js rename to test/unit/features/options/errorCaptured.spec.js index 27a12145fc..a0454ade0e 100644 --- a/test/unit/features/options/catchError.spec.js +++ b/test/unit/features/options/errorCaptured.spec.js @@ -1,6 +1,6 @@ import Vue from 'vue' -describe('Options catchError', () => { +describe('Options errorCaptured', () => { let globalSpy beforeEach(() => { @@ -26,7 +26,7 @@ describe('Options catchError', () => { } new Vue({ - catchError: spy, + errorCaptured: spy, render: h => h(Child) }).$mount() @@ -49,7 +49,7 @@ describe('Options catchError', () => { data: { error: null }, - catchError (e, vm, info) { + errorCaptured (e, vm, info) { expect(vm).toBe(child) this.error = e.toString() + ' in ' + info }, @@ -82,7 +82,7 @@ describe('Options catchError', () => { } new Vue({ - catchError (err, vm, info) { + errorCaptured (err, vm, info) { spy(err, vm, info) return true }, @@ -108,7 +108,7 @@ describe('Options catchError', () => { let err2 const vm = new Vue({ - catchError () { + errorCaptured () { err2 = new Error('foo') throw err2 }, @@ -116,6 +116,6 @@ describe('Options catchError', () => { }).$mount() expect(globalSpy).toHaveBeenCalledWith(err, child, 'created hook') - expect(globalSpy).toHaveBeenCalledWith(err2, vm, 'catchError') + expect(globalSpy).toHaveBeenCalledWith(err2, vm, 'errorCaptured hook') }) })