Skip to content

Commit

Permalink
log a better error message when failing to mount an extension as an e…
Browse files Browse the repository at this point in the history
…xpress app
  • Loading branch information
Alex Van Camp committed Feb 17, 2015
1 parent dc9ffbd commit 369c1a2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/server/extensions.js
Expand Up @@ -77,7 +77,7 @@ function _loadExtension(bundle) {
try {
var extension = require(extPath)(new ExtensionApi(bundle));
if (bundle.extension.express) {
expressExtensions.push(extension);
expressExtensions.push([extension, bundle.name]);
log.info('Mounted %s extension as an express app', bundle.name);
} else {
log.info('Mounted %s extension as a generic extension', bundle.name);
Expand Down
12 changes: 10 additions & 2 deletions lib/server/index.js
Expand Up @@ -54,8 +54,16 @@ exports.start = function() {

extensionManager = require('./extensions.js');
extensionManager.on('extensionsLoaded', function() {
extensionManager.getExpressExtensions().forEach(function(extension) {
app.use(extension);
extensionManager.getExpressExtensions().forEach(function(extData) {
var extension = extData[0];
var name = extData[1];
try {
app.use(extension);
} catch(e) {
log.error('Failed to mount extension for bundle "%s" as an express app.'
+ '\n\tEither make sure your extension is actually exporting an express app,'
+ '\n\tor set "extension.express" to "false" in your nodecg.json', name);
}
});

exports.emit('extensionsLoaded');
Expand Down

0 comments on commit 369c1a2

Please sign in to comment.