diff --git a/run.js b/run.js index d6237fc..69dc02b 100644 --- a/run.js +++ b/run.js @@ -155,9 +155,16 @@ DBot.prototype.reloadModules = function() { this.instance.removeListeners(); moduleNames.each(function(name) { + this.status[name] = true; + var moduleDir = './modules/' + name + '/'; - var cacheKey = require.resolve(moduleDir + name); - delete require.cache[cacheKey]; + try { + var cacheKey = require.resolve(moduleDir + name); + delete require.cache[cacheKey]; + } catch(err) { + this.status[name] = 'Error loading module: ' + err + ' ' + err.stack.split('\n')[2].trim(); + return; + } try { var webKey = require.resolve(moduleDir + 'web'); @@ -167,8 +174,6 @@ DBot.prototype.reloadModules = function() { delete require.cache[webKey]; } - this.status[name] = true; - try { // Load the module config data var config = {};