From c704eda6b68484f0e320dbfde505085c1b86fc31 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sat, 21 Feb 2015 04:43:10 +0000 Subject: [PATCH] catch more error cases --- lib/vhost-sni-server.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/vhost-sni-server.js b/lib/vhost-sni-server.js index c4059dd..3be38ea 100644 --- a/lib/vhost-sni-server.js +++ b/lib/vhost-sni-server.js @@ -87,6 +87,11 @@ module.exports.create = function (securePort, certsPath, vhostsdir) { console.log('[log] LOADING "' + domaininfo.hostname + '/' + domaininfo.pathname + '"'); getAppContext(domaininfo).then(function (localApp) { + //if (localApp.arity >= 2) { /* connect uses .apply(null, arguments)*/ } + if ('function' !== typeof localApp) { + localApp = getDummyAppContext(null, "[ERROR] no connect-style export from " + domaininfo.dirname); + } + // Note: pathname should NEVER have a leading '/' on its own // we always add it explicitly try { @@ -156,10 +161,12 @@ module.exports.create = function (securePort, certsPath, vhostsdir) { , port: securePort , url: domaininfo.pathname }); + if (!localApp) { - return getDummyAppContext(null, "[ERROR] no app was returned by app.js for " + domaininfo.driname); + localApp = getDummyAppContext(null, "[ERROR] no app was returned by app.js for " + domaininfo.dirname); } } + if (!localApp.then) { localApp = PromiseA.resolve(localApp); } else { @@ -170,8 +177,6 @@ module.exports.create = function (securePort, certsPath, vhostsdir) { } catch(e) { localApp = getDummyAppContext(e, "[ERROR] could not load app.js for " + domaininfo.dirname); localApp = PromiseA.resolve(localApp); - - return localApp; } return localApp;