Changed privmsgs.getArgs to raise ArgumentError, and make the necessary changes in callbacks to Do The Right Thing

This commit is contained in:
Jeremy Fincher 2003-03-31 22:22:59 +00:00
parent df77cfaccf
commit 46f3012f9a
2 changed files with 7 additions and 5 deletions

View File

@ -150,6 +150,9 @@ class Error(Exception):
"""Generic class for errors in Privmsg callbacks."""
pass
class ArgumentError(Error):
pass
class Tokenizer:
quotes = '"`'
nonbacktickquotes = '"'
@ -237,11 +240,10 @@ class IrcObjectProxy:
else:
command = getattr(callback, name)
callback.callCommand(command, self, self.msg, self.args)
except ArgumentError:
self.reply(self.msg, command.__doc__.splitlines()[0])
except Error, e:
if str(e) == '':
self.reply(self.msg, command.__doc__.splitlines()[0])
else:
self.reply(self.msg, debug.exnToString(e))
self.reply(self.msg, debug.exnToString(e))
except Exception, e:
debug.recoverableException()
self.reply(self.msg, debug.exnToString(e))

View File

@ -69,7 +69,7 @@ def getArgs(args, needed=1, optional=0):
let the caller handle sending the help message.
"""
if len(args) < needed:
raise callbacks.Error
raise callbacks.ArgumentError
if len(args) < needed + optional:
ret = list(args) + ([''] * (needed + optional - len(args)))
elif len(args) >= needed + optional: