From c1df7cd1fc629ef121cfa538f07dd0d81525a988 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 10 Apr 2014 12:01:02 +0200 Subject: [PATCH] Handle missing sections/options in :set --- qutebrowser/config/config.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py index ffe714e01..45ce8af58 100644 --- a/qutebrowser/config/config.py +++ b/qutebrowser/config/config.py @@ -235,9 +235,24 @@ class Config: newval = val.typ.transform(newval) return newval - @cmdutils.register(instance='config', completion=['section', 'option']) - def set(self, section, option, value): + @cmdutils.register(name='set', instance='config', + completion=['section', 'option']) + def set_wrapper(self, section, option, value): + """Set an option. + + Wrapper for self.set() to output exceptions in the status bar. + + Arguments: + *args: Get passed to self.set(). + + """ # FIXME completion for values + try: + self.set(section, option, value) + except (NoOptionError, NoSectionError) as e: + message.error("set: {} - {}".format(e.__class__.__name__, e)) + + def set(self, section, option, value): """Set an option.""" if value: value = self._interpolation.before_set(self, section, option,