From 1d8bd15a77dfc5fdf7199c64278379a6143aed00 Mon Sep 17 00:00:00 2001 From: Bryan Clark Date: Tue, 14 Apr 2015 09:09:18 -0700 Subject: [PATCH] add console.error message to a bad require in a boot script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change produces the following error message in the tests: `Failed loading boot script badScript.js` `Cannot find module 'doesnt-exist’` --- lib/executor.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/executor.js b/lib/executor.js index 5251d3f..43b2fca 100644 --- a/lib/executor.js +++ b/lib/executor.js @@ -231,13 +231,18 @@ function runScripts(app, list, callback) { var functions = []; list.forEach(function(filepath) { debug('Requiring script %s', filepath); - var exports = require(filepath); - if (typeof exports === 'function') { - debug('Exported function detected %s', filepath); - functions.push({ - path: filepath, - func: exports - }); + try { + var exports = require(filepath); + if (typeof exports === 'function') { + debug('Exported function detected %s', filepath); + functions.push({ + path: filepath, + func: exports + }); + } + } catch (err) { + console.error('Failed loading boot script: %s\n%s', filepath, err.stack); + throw err; } });