catch more error cases

This commit is contained in:
AJ ONeal 2015-02-21 04:43:10 +00:00
parent e7d0769270
commit c704eda6b6
1 changed files with 8 additions and 3 deletions

View File

@ -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;