forked from GitHub/dbot
domain err catch
This commit is contained in:
parent
b3d7abbc3b
commit
a101cfe437
@ -4,7 +4,8 @@
|
|||||||
* command and then runs that command, given the user isn't banned from or
|
* command and then runs that command, given the user isn't banned from or
|
||||||
* ignoring that command.
|
* ignoring that command.
|
||||||
*/
|
*/
|
||||||
var _ = require('underscore')._;
|
var _ = require('underscore')._,
|
||||||
|
cDomain = require('domain').create();
|
||||||
|
|
||||||
var command = function(dbot) {
|
var command = function(dbot) {
|
||||||
/**
|
/**
|
||||||
@ -72,6 +73,7 @@ var command = function(dbot) {
|
|||||||
} else if(!isIgnoring && _.has(dbot.commands, commandName) && !dbot.commands[commandName].disabled) {
|
} else if(!isIgnoring && _.has(dbot.commands, commandName) && !dbot.commands[commandName].disabled) {
|
||||||
if(this.api.applyRegex(commandName, event)) {
|
if(this.api.applyRegex(commandName, event)) {
|
||||||
try {
|
try {
|
||||||
|
cDomain.run(function() {
|
||||||
var command = dbot.commands[commandName],
|
var command = dbot.commands[commandName],
|
||||||
results;
|
results;
|
||||||
if(_.has(command, 'resolver')) {
|
if(_.has(command, 'resolver')) {
|
||||||
@ -84,6 +86,7 @@ var command = function(dbot) {
|
|||||||
} else {
|
} else {
|
||||||
results = command.apply(dbot.modules[command.module], [event]);
|
results = command.apply(dbot.modules[command.module], [event]);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
if(dbot.config.debugMode == true) {
|
if(dbot.config.debugMode == true) {
|
||||||
var stack = err.stack.split('\n').slice(1, dbot.config.debugLevel + 1);
|
var stack = err.stack.split('\n').slice(1, dbot.config.debugLevel + 1);
|
||||||
@ -119,6 +122,15 @@ var command = function(dbot) {
|
|||||||
// Not sure this is the right place for this. Perhaps they should be in
|
// Not sure this is the right place for this. Perhaps they should be in
|
||||||
// another file?
|
// another file?
|
||||||
|
|
||||||
|
cDomain.on('error', function(err) {
|
||||||
|
console.log(err); // Hmm
|
||||||
|
if(_.has(dbot.modules, 'log')) {
|
||||||
|
// can't really get context
|
||||||
|
var server = _.keys(dbot.config.servers)[0];
|
||||||
|
dbot.api.log.log(server, dbot.config.name, '[\u00034ERR\u000f] ' + err.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
dbot.access = {
|
dbot.access = {
|
||||||
'admin': function(event) {
|
'admin': function(event) {
|
||||||
return dbot.config.admins;
|
return dbot.config.admins;
|
||||||
|
Loading…
Reference in New Issue
Block a user