Do not continue to load module if data file syntax error occurs [#466]

This commit is contained in:
reality 2013-05-26 15:21:13 +00:00
parent 3148b3e434
commit bc7bac1218

4
run.js
View File

@ -186,7 +186,7 @@ DBot.prototype.reloadModules = function() {
defaultConfig = JSON.parse(defaultConfig); defaultConfig = JSON.parse(defaultConfig);
} catch(err) { // syntax error } catch(err) { // syntax error
this.status[name] = 'Error parsing config: ' + err + ' ' + err.stack.split('\n')[2].trim(); this.status[name] = 'Error parsing config: ' + err + ' ' + err.stack.split('\n')[2].trim();
return; continue;
} }
config = _.defaults(config, defaultConfig); config = _.defaults(config, defaultConfig);
} catch(err) { } catch(err) {
@ -220,6 +220,7 @@ DBot.prototype.reloadModules = function() {
process.nextTick(function() { process.nextTick(function() {
_.each(moduleNames, function(name) { _.each(moduleNames, function(name) {
if(this.status[name] === true) {
try { try {
var moduleDir = './modules/' + name + '/'; var moduleDir = './modules/' + name + '/';
var rawModule = require(moduleDir + name); var rawModule = require(moduleDir + name);
@ -301,6 +302,7 @@ DBot.prototype.reloadModules = function() {
} }
this.modules[module.name] = module; this.modules[module.name] = module;
}
}.bind(this)); }.bind(this));
}.bind(this)); }.bind(this));