2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-22 01:22:00 +00:00

Try for more informative messoge an expression syntax error

This commit is contained in:
Jarrod Johnson 2022-02-11 14:51:53 -05:00
parent f0c4943612
commit bd428790ce

View File

@ -218,7 +218,12 @@ def _expand_expression(nodes, configmanager, inputdata):
pernodeexpressions[expanded[0]] = expanded[1]
for node in util.natural_sort(pernodeexpressions):
yield msg.KeyValueData({'value': pernodeexpressions[node]}, node)
except (SyntaxError, ValueError) as e:
except SyntaxError as e:
markup = (e.text[:e.offset-1] + '-->' + e.text[e.offset-1] + '<--' + e.text[e.offset:]).strip()
raise exc.InvalidArgumentException(
'Bad confluent expression syntax (must use "{{" and "}}" if not '
'desiring confluent expansion): ' + markup)
except ValueError as e:
raise exc.InvalidArgumentException(
'Bad confluent expression syntax (must use "{{" and "}}" if not '
'desiring confluent expansion): ' + str(e))