Commit 088d0cc5 authored by Guillaume Seguin's avatar Guillaume Seguin

Allow marking exceptions as coming from setting validator

This way we know that the error does not come from the setter itself but
from the validator and can report in a better way the error
parent 0ee5bfd6
...@@ -852,9 +852,12 @@ class pronsole(cmd.Cmd): ...@@ -852,9 +852,12 @@ class pronsole(cmd.Cmd):
if not self.processing_rc and not self.processing_args: if not self.processing_rc and not self.processing_args:
self.save_in_rc("set " + var, "set %s %s" % (var, value)) self.save_in_rc("set " + var, "set %s %s" % (var, value))
except AttributeError: except AttributeError:
logging.debug("Unknown variable '%s'" % var) logging.debug(_("Unknown variable '%s'") % var)
except ValueError, ve: except ValueError, ve:
self.logError("Bad value for variable '%s', expecting %s (%s)" % (var, repr(t)[1:-1], ve.args[0])) if hasattr(ve, "from_validator"):
self.logError(_("Bad value %s for variable '%s': %s") % (str, var, ve.args[0]))
else:
self.logError(_("Bad value for variable '%s', expecting %s (%s)") % (var, repr(t)[1:-1], ve.args[0]))
def do_set(self, argl): def do_set(self, argl):
args = argl.split(None, 1) args = argl.split(None, 1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment