From 0705d6087cf1f7519d1664c9ae53ef0a7053f1d3 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 10 Jul 2014 22:38:09 +0200 Subject: [PATCH] Don't catch every ValueError to get failed interpolations --- qutebrowser/app.py | 4 ++-- qutebrowser/config/config.py | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/qutebrowser/app.py b/qutebrowser/app.py index 8e18b3adc..bb93a6706 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -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) diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py index 84bfac3e7..f92acb134 100644 --- a/qutebrowser/config/config.py +++ b/qutebrowser/config/config.py @@ -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: