raises ValueError exception if conditional is not parsable (#17788)
The Conditional class now raises a ValueError with message if it cannot correclty parse the passed in conditional. This makes it easier to detect issues in modules that specify conditionals.
This commit is contained in:
parent
6d78397b8b
commit
605152e61b
1 changed files with 6 additions and 1 deletions
|
@ -42,6 +42,7 @@ def to_list(val):
|
|||
else:
|
||||
return list()
|
||||
|
||||
|
||||
class FailedConditionsError(Exception):
|
||||
def __init__(self, msg, failed_conditions):
|
||||
super(FailedConditionsError, self).__init__(msg)
|
||||
|
@ -192,7 +193,11 @@ class Conditional(object):
|
|||
self.raw = conditional
|
||||
self.encoding = encoding
|
||||
|
||||
key, op, val = shlex.split(conditional)
|
||||
try:
|
||||
key, op, val = shlex.split(conditional)
|
||||
except ValueError:
|
||||
raise ValueError('failed to parse conditional')
|
||||
|
||||
self.key = key
|
||||
self.func = self._func(op)
|
||||
self.value = self._cast_value(val)
|
||||
|
|
Loading…
Reference in a new issue