summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-03-20 12:49:13 +0100
committerGitHub <noreply@github.com>2020-03-20 12:49:13 +0100
commitaca6154bfd25cf62dbbce21d6a3bf56024f62035 (patch)
treefeafd567991de130d627dd8401e7d6552846f57a
parent86e504525f961c461389f48f808a51df73eb337f (diff)
parentaa58a9b545ca59ab2e6c817ec0c3c8cfdbf9ce75 (diff)
downloadvyos-1x-aca6154bfd25cf62dbbce21d6a3bf56024f62035.tar.gz
vyos-1x-aca6154bfd25cf62dbbce21d6a3bf56024f62035.zip
Merge pull request #250 from thomas-mangin/T2057-convert
ifconfig: T2057: data conversion was lost, better error message
-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)