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.
pull/17791/head
Peter Sprygada 8 years ago committed by GitHub
parent 6d78397b8b
commit 605152e61b

@ -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…
Cancel
Save