add more user-friendly message on condition parsing error

This commit is contained in:
Christophe Benz 2010-06-21 17:50:50 +02:00
commit 2ed5c7f5e5

View file

@ -73,6 +73,7 @@ class ResultsCondition(object):
condition_str.replace('AND', 'and') condition_str.replace('AND', 'and')
condition_str.replace('NOT', 'not') condition_str.replace('NOT', 'not')
or_list = [] or_list = []
try:
for _or in condition_str.split('or'): for _or in condition_str.split('or'):
and_dict = {} and_dict = {}
for _and in _or.split('and'): for _and in _or.split('and'):
@ -85,6 +86,8 @@ class ResultsCondition(object):
raise ResultsConditionException(u'Could not find = or != operator in sub-expression "%s"' % _and) raise ResultsConditionException(u'Could not find = or != operator in sub-expression "%s"' % _and)
and_dict[k] = v and_dict[k] = v
or_list.append(and_dict) or_list.append(and_dict)
except:
raise ResultsConditionException(u'Could not parse condition expression "%s"' % condition_str)
self.condition = or_list self.condition = or_list
def is_valid(self, d): def is_valid(self, d):