From aa58a9b545ca59ab2e6c817ec0c3c8cfdbf9ce75 Mon Sep 17 00:00:00 2001 From: Thomas Mangin Date: Fri, 20 Mar 2020 11:28:04 +0000 Subject: ifconfig: T2057: data conversion was lost, better error message --- python/vyos/ifconfig/control.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/python/vyos/ifconfig/control.py b/python/vyos/ifconfig/control.py index 508b4e279..c8568ac96 100644 --- a/python/vyos/ifconfig/control.py +++ b/python/vyos/ifconfig/control.py @@ -55,14 +55,17 @@ class Control: validate = self._command_set[name].get('validate', None) if validate: - validate(value) - - config = {**config, **{'value': value}} + try: + validate(value) + except Exception as e: + raise e.__class__(f'Could not set {name}. {e}') convert = self._command_set[name].get('convert', None) if convert: value = convert(value) + config = {**config, **{'value': value}} + cmd = self._command_set[name]['shellcmd'].format(**config) return self._cmd(cmd) -- cgit v1.2.3