Fixed bug #1059544, InvalidRegistryValues can now show what the name of the registry value is.

This commit is contained in:
Jeremy Fincher 2004-11-03 22:58:20 +00:00
parent 54f77f914b
commit a060f26aa8
2 changed files with 21 additions and 7 deletions

View File

@ -206,7 +206,18 @@ if __name__ == '__main__':
sys.stderr.write(os.linesep)
sys.exit(-1)
import supybot.log as log
try:
import supybot.log as log
except supybot.registry.InvalidRegistryValue, e:
# This is raised here because supybot.log imports supybot.conf.
name = e.value._name
errmsg = textwrap.fill('%s: %s' % (name, e),
width=78, subsequent_indent=' '*len(name))
sys.stderr.write(errmsg)
sys.stderr.write('\n')
sys.stderr.write('Please fix this error in your configuration file '
'and restart your bot.\n')
sys.exit(-1)
import supybot.conf as conf
import supybot.world as world
world.starting = True

View File

@ -306,7 +306,9 @@ class Value(Group):
else:
s = """Invalid registry value. If you're getting this message,
report it, because we forgot to put a proper help string here."""
raise InvalidRegistryValue, utils.normalizeWhitespace(s)
e = InvalidRegistryValue(utils.normalizeWhitespace(s))
e.value = self
raise e
def setName(self, *args):
if self._name == 'unset':
@ -445,9 +447,9 @@ class OnlySomeStrings(String):
(self._help, utils.commaAndify(strings))
def error(self):
raise InvalidRegistryValue, \
'That is not a valid value. Valid values include %s.' % \
utils.commaAndify(map(repr, self.validStrings))
self.__parent.error('That is not a valid value. '
'Valid values include %s.' % \
utils.commaAndify(map(repr, self.validStrings)))
def normalize(self, s):
lowered = s.lower()
@ -517,10 +519,11 @@ class Regexp(Value):
kwargs['setDefault'] = False
self.sr = ''
self.value = None
super(Regexp, self).__init__(*args, **kwargs)
self.__parent = super(Regexp, self)
self.__parent.__init__(*args, **kwargs)
def error(self, e):
raise InvalidRegistryValue, 'Value must be a regexp of the form %s' % e
self.__parent.error('Value must be a regexp of the form %s' % e)
def set(self, s):
try: