Don't catch every ValueError to get failed interpolations

This commit is contained in:
Florian Bruhin 2014-07-10 22:38:09 +02:00
parent f0c67193a9
commit 0705d6087c
2 changed files with 14 additions and 3 deletions

View File

@ -180,11 +180,11 @@ class Application(QApplication):
self.config = ConfigManager(confdir, 'qutebrowser.conf', self)
except (config.ValidationError,
config.NoOptionError,
config.InterpolationSyntaxError,
configparser.InterpolationError,
configparser.DuplicateSectionError,
configparser.DuplicateOptionError,
configparser.ParsingError,
ValueError) as e:
configparser.ParsingError) as e:
errstr = "Error while reading config:"
if hasattr(e, 'section') and hasattr(e, 'option'):
errstr += "\n\n{} -> {}:".format(e.section, e.option)

View File

@ -71,6 +71,13 @@ class NoOptionError(configparser.NoOptionError):
pass
class InterpolationSyntaxError(ValueError):
"""Exception raised when configparser interpolation raised an error."""
pass
class ConfigManager(QObject):
"""Configuration manager for qutebrowser.
@ -361,7 +368,11 @@ class ConfigManager(QObject):
changed: If the config was changed.
style_changed: When style caches need to be invalidated.
"""
value = self._interpolation.before_set(self, sectname, optname, value)
try:
value = self._interpolation.before_set(self, sectname, optname,
value)
except ValueError as e:
raise InterpolationSyntaxError(e)
try:
sect = self.sections[sectname]
except KeyError: