From e8bba56f1ff5c0b599ab8c40e2bcfabde68e1165 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Tue, 20 Jan 2004 22:26:48 +0000 Subject: [PATCH] Added supybot.reply.detailedErrors. --- src/callbacks.py | 18 ++++++++++++------ src/conf.py | 4 ++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/callbacks.py b/src/callbacks.py index 075ab6f2c..db7b55411 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -423,10 +423,10 @@ class IrcObjectProxy(RichReplyMethods): self.error(str(e)) except Exception, e: cb.log.exception('Uncaught exception:') - # TODO: Configuration variable for this detailed error. Users - # should be able to specify that a plain error message get - # returned. - self.error(utils.exnToString(e)) + if conf.supybot.reply.detailedErrors(): + self.error(utils.exnToString(e)) + else: + self.replyError() def finalEval(self): assert not self.finalEvaled, 'finalEval called twice.' @@ -815,7 +815,10 @@ class PrivmsgRegexp(Privmsg): # We catch exceptions here because IrcObjectProxy isn't doing our # dirty work for us anymore. self.log.exception('Uncaught exception from callCommand:') - irc.error(utils.exnToString(e)) + if conf.supybot.reply.detailedErrors(): + irc.error(utils.exnToString(e)) + else: + irc.replyError() def doPrivmsg(self, irc, msg): if Privmsg.errored: @@ -863,7 +866,10 @@ class PrivmsgCommandAndRegexp(Privmsg): except Exception, e: if 'catchErrors' in kwargs and kwargs['catchErrors']: self.log.exception('Uncaught exception in callCommand:') - irc.error(utils.exnToString(e)) + if conf.supybot.reply.detailedErrors(): + irc.error(utils.exnToString(e)) + else: + irc.replyError() else: raise diff --git a/src/conf.py b/src/conf.py index 74ec9cf00..d399dbdba 100644 --- a/src/conf.py +++ b/src/conf.py @@ -163,6 +163,10 @@ the bot will send multi-message replies in a single messsage or in multiple messages. For safety purposes (so the bot can't possibly flood) it will normally send everything in a single message.""")) +supybot.reply.register('detailedErrors', registry.Boolean(True, """Determines +whether error messages that result from bugs in the bot will show a detailed +error message (the uncaught exception) or a generic error message.""")) + supybot.reply.register('errorInPrivate', registry.Boolean(False, """ Determines whether the bot will send error messages to users in private."""))