summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--python/vyos/ifconfig/control.py9
1 files 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)