Comparing version 1.0.2 to 1.0.3
15
index.js
@@ -17,3 +17,3 @@ const Package = require('./package.json'); | ||
// provided in the handler and we just returned by default. | ||
if (handlerResult === undefined && pluginOptions.skipUndefined) { | ||
if (pluginOptions.skipUndefined && handlerResult === undefined) { | ||
request.log(['handler'], | ||
@@ -23,3 +23,3 @@ `Undefined return value ignored in generator handler ${handler.name}`); | ||
} | ||
// If the success result of the handler is an error either: | ||
@@ -31,3 +31,5 @@ // 1. An error was returned. | ||
// For this reason, if it is an error, we just ignore it. | ||
if (handlerResult !== undefined && handlerResult.isBoom && pluginOptions.skipReturnError) { | ||
if (pluginOptions.skipReturnError && | ||
handlerResult instanceof Error && | ||
handlerResult.isBoom) { | ||
request.log(['handler'], `Unthrown error ignored in generator handler ${handler.name}`); | ||
@@ -41,7 +43,8 @@ return; | ||
// is probably enough to determine that reply was already called and we should do nothing. | ||
if (handlerResult !== undefined && | ||
if (pluginOptions.skipReturnReply && | ||
handlerResult !== undefined && | ||
handlerResult !== null && | ||
handlerResult.statusCode !== undefined && | ||
handlerResult.headers !== undefined && | ||
handlerResult.source !== undefined && | ||
pluginOptions.skipReturnReply) { | ||
handlerResult.source !== undefined) { | ||
return; | ||
@@ -48,0 +51,0 @@ } |
{ | ||
"name": "kookaburra", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Kookaburra is a Hapi plugin that lets you use generator function coroutines as handlers using Bluebird", | ||
@@ -5,0 +5,0 @@ "repository": "xargi/kookaburra", |
@@ -35,3 +35,3 @@ # Kookaburra | ||
- patchAll: | ||
- Automatically patch all detected generator handlers in route tables. If disabled, you must use the ```handler: { coroutine: *fn() {...} }``` syntax. Default value: ```true```. | ||
- Automatically patch all detected generator handlers in route tables. If disabled, you must use the ```handler: { coroutine: *fn() {...} }``` syntax to define a handler. Default value: ```true```. | ||
- skipReturnReply: | ||
@@ -38,0 +38,0 @@ - Skip replying when a ```return reply();``` return value is detected. If disabled, you shouldn't use that syntax, but it may allow avoiding a falsely detected reply call. Default value: ```true```. |
@@ -0,0 +0,0 @@ const Hapi = require('hapi'); |
Sorry, the diff of this file is not supported yet
9564
152