From 506d50e1d67055c8bddb703cc30f30df952848d7 Mon Sep 17 00:00:00 2001 From: David Luecke Date: Thu, 8 Feb 2018 15:44:33 -0800 Subject: [PATCH 1/4] Updating changelog --- changelog.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/changelog.md b/changelog.md index f71254aeb0..7857db5369 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,13 @@ # Change Log +## [v3.1.1](https://github.com/feathersjs/feathers/tree/v3.1.1) (2018-02-08) +[Full Changelog](https://github.com/feathersjs/feathers/compare/v3.1.0...v3.1.1) + +**Merged pull requests:** + +- Turn argument validation into the first hook [\#818](https://github.com/feathersjs/feathers/pull/818) ([daffl](https://github.com/daffl)) +- Add Russian Telegram community [\#814](https://github.com/feathersjs/feathers/pull/814) ([vodniciarv](https://github.com/vodniciarv)) + ## [v3.1.0](https://github.com/feathersjs/feathers/tree/v3.1.0) (2018-01-26) [Full Changelog](https://github.com/feathersjs/feathers/compare/v3.0.5...v3.1.0) From 21089f05173a68f058fa1c0a4ba1666cf3a2a198 Mon Sep 17 00:00:00 2001 From: David Luecke Date: Sat, 10 Feb 2018 10:35:32 -0800 Subject: [PATCH 2/4] Handle errors in error hooks properly (#819) --- lib/hooks.js | 8 ++++++-- test/hooks/hooks.test.js | 25 ++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/lib/hooks.js b/lib/hooks.js index 9596360dfb..8d95958d69 100644 --- a/lib/hooks.js +++ b/lib/hooks.js @@ -105,8 +105,12 @@ const hookMixin = exports.hookMixin = function hookMixin (service) { error }); - return processHooks - .call(service, hookChain, errorHookObject) + return processHooks.call(service, hookChain, errorHookObject) + .catch(error => { + errorHookObject.error = error; + + return errorHookObject; + }) .then(hook => { if (returnHook) { // Either resolve or reject with the hook object diff --git a/test/hooks/hooks.test.js b/test/hooks/hooks.test.js index d361d6ac32..afeb1b3224 100644 --- a/test/hooks/hooks.test.js +++ b/test/hooks/hooks.test.js @@ -182,7 +182,7 @@ describe('hooks basics', () => { }); }); - it('on argument validation error', () => { + it('on argument validation error (https://github.com/feathersjs/express/issues/19)', () => { const app = feathers().use('/dummy', { get (id) { return Promise.resolve({ id }); @@ -197,6 +197,29 @@ describe('hooks basics', () => { }); }); + it('on error in error hook (https://github.com/feathersjs/express/issues/21)', () => { + const app = feathers().use('/dummy', { + get (id) { + return Promise.reject(new Error('Nope')); + } + }); + + app.service('dummy').hooks({ + error: { + get (context) { + throw new Error('Error in error hook'); + } + } + }); + + return app.service('dummy').get(10, {}, true).catch(context => { + assert.equal(context.service, app.service('dummy')); + assert.equal(context.type, 'error'); + assert.equal(context.path, 'dummy'); + assert.equal(context.error.message, 'Error in error hook'); + }); + }); + it('still swallows error if context.result is set', () => { const result = { message: 'this is a test' }; const app = feathers().use('/dummy', { From 8c77846a43ad3bf1d9886b1690680d7c2ca48f9b Mon Sep 17 00:00:00 2001 From: David Luecke Date: Sat, 10 Feb 2018 10:35:59 -0800 Subject: [PATCH 3/4] Updating version --- lib/version.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/version.js b/lib/version.js index 8eb98595f3..a2dbd8817a 100644 --- a/lib/version.js +++ b/lib/version.js @@ -1 +1 @@ -module.exports = '3.1.1'; +module.exports = '3.1.2'; diff --git a/package.json b/package.json index d3ff4d3bc2..df2f36ac64 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@feathersjs/feathers", "description": "A REST and realtime API layer for modern applications.", - "version": "3.1.1", + "version": "3.1.2", "homepage": "http://feathersjs.com", "repository": { "type": "git", From 113ab7b4fb86d52a242afdd3a7506b641010bdff Mon Sep 17 00:00:00 2001 From: David Luecke Date: Sat, 10 Feb 2018 10:35:59 -0800 Subject: [PATCH 4/4] 3.1.2 --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 50cc27cf44..2ea1b94f37 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@feathersjs/feathers", - "version": "3.1.1", + "version": "3.1.2", "lockfileVersion": 1, "requires": true, "dependencies": {