Skip to content

Commit

Permalink
Assign pre errors to both pre and preResponses. Closes #3431
Browse files Browse the repository at this point in the history
  • Loading branch information
hueniverse committed May 29, 2017
1 parent 98efaef commit a270c69
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ internals.pre = function (pre) {
}

if (pre.assign) {
request.pre[pre.assign] = response.source;
request.pre[pre.assign] = (response instanceof Error ? response : response.source);
request.preResponses[pre.assign] = response;
}

Expand Down
8 changes: 7 additions & 1 deletion test/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,13 @@ describe('handler', () => {
],
handler: function (request, reply) {

return reply('ok');
if (request.pre.before === request.preResponses.before &&
request.pre.before instanceof Error) {

return reply('ok');
}

return reply(new Error());
}
}
});
Expand Down

0 comments on commit a270c69

Please sign in to comment.