Comparing version 1.0.1 to 1.0.2
21
index.js
@@ -15,2 +15,10 @@ const Package = require('./package.json'); | ||
.then((handlerResult) => { | ||
// If the handlerResult is undefined, it's probably because the value was already | ||
// provided in the handler and we just returned by default. | ||
if (handlerResult === undefined && pluginOptions.skipUndefined) { | ||
request.log(['handler'], | ||
`Undefined return value ignored in generator handler ${handler.name}`); | ||
return; | ||
} | ||
// If the success result of the handler is an error either: | ||
@@ -22,3 +30,3 @@ // 1. An error was returned. | ||
// For this reason, if it is an error, we just ignore it. | ||
if (handlerResult.isBoom && pluginOptions.skipReturnError) { | ||
if (handlerResult !== undefined && handlerResult.isBoom && pluginOptions.skipReturnError) { | ||
request.log(['handler'], `Unthrown error ignored in generator handler ${handler.name}`); | ||
@@ -32,3 +40,4 @@ return; | ||
// is probably enough to determine that reply was already called and we should do nothing. | ||
if (handlerResult.statusCode !== undefined && | ||
if (handlerResult !== undefined && | ||
handlerResult.statusCode !== undefined && | ||
handlerResult.headers !== undefined && | ||
@@ -40,10 +49,2 @@ handlerResult.source !== undefined && | ||
// If the handlerResult is undefined, it's probably because the value was already | ||
// provided in the handler and we just returned by default. | ||
if (handlerResult === undefined && pluginOptions.skipUndefined) { | ||
request.log(['handler'], | ||
`Undefined return value ignored in generator handler ${handler.name}`); | ||
return; | ||
} | ||
// In every other case, reply with the return value | ||
@@ -50,0 +51,0 @@ reply(handlerResult); |
{ | ||
"name": "kookaburra", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Kookaburra is a Hapi plugin that lets you use generator function coroutines as handlers using Bluebird", | ||
@@ -5,0 +5,0 @@ "repository": "xargi/kookaburra", |
@@ -0,0 +0,0 @@ # Kookaburra |
@@ -0,0 +0,0 @@ const Hapi = require('hapi'); |
Sorry, the diff of this file is not supported yet
149
9265