3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-23 20:39:25 +01:00

Add a debug mode that shows the error and the top of the stack trace in the case of an error if activated.

This commit is contained in:
reality 2012-12-23 02:25:58 +00:00
parent 950ba882b8
commit 81217ece50
3 changed files with 12 additions and 3 deletions

View File

@ -13,5 +13,6 @@
},
"admins": [ "batman" ],
"moduleNames": [ "ignore", "admin", "command", "dice", "js", "kick", "puns", "quotes", "spelling", "youare" ],
"language": "english"
"language": "english",
"debugMode": true
}

View File

@ -79,7 +79,15 @@ var command = function(dbot) {
} else {
if(!isIgnoring(event.user, commandName)) {
if(applyRegex(commandName, event)) {
dbot.commands[commandName](event);
try {
dbot.commands[commandName](event);
} catch(err) {
if(dbot.config.debugMode == true) {
event.reply('- Error in ' + commandName + ':');
event.reply('- Message: ' + err);
event.reply('- Top of stack: ' + err.stack.split('\n')[1].trim());
}
}
dbot.save();
} else {
if(commandName !== '~') {

2
run.js
View File

@ -5,7 +5,7 @@ require('./snippets');
var DBot = function(timers) {
// Load external files
var requiredConfigKeys = [ 'name', 'servers', 'admins', 'moduleNames', 'language' ];
var requiredConfigKeys = [ 'name', 'servers', 'admins', 'moduleNames', 'language', 'debugMode' ];
try {
this.config = JSON.parse(fs.readFileSync('config.json', 'utf-8'));
} catch(err) {