Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message for unmatched input #214

Closed
tsandall opened this issue Jan 16, 2017 · 1 comment · Fixed by #430
Closed

Improve error message for unmatched input #214

tsandall opened this issue Jan 16, 2017 · 1 comment · Fixed by #430

Comments

@tsandall
Copy link
Member

tsandall commented Jan 16, 2017

If the parser fails to find a matching rule, it stops immediately and returns an error message as follows:

1 error occurred: /Users/torin/test.rego:3: no match found, unexpected ','

It would be nice if the error message contained more context such as the surrounding text.

In some cases, the error message is slightly misleading, for instance:

test.rego:

package ex

limit :- input.value >= .5

error:

1 error occurred: /Users/torin/test.rego:3: no match found, unexpected '>'

The floating point number doesn't parse however because of how expressions are matched, it fails at >.

It's possible the parser rules could be restructured to improve error handling however this seems like something the parser should be able to deal with.

Creating this ticket as a placeholder for more investigation into improvements.

@tsandall
Copy link
Member Author

tsandall commented Jul 6, 2017

We can improve error messages by implementing code blocks as described here: mna/pigeon#18 (comment).

tsandall added a commit to tsandall/opa that referenced this issue Aug 29, 2017
The new version of mna/pigeon fixes the location bug that prevented
accurate line/column numbers from being reported on unmatched input.

In the future we can investigate improvements to the error messages by
adding negative matches that return higher-level errors as long as the
location information is not impacted.

Fixes open-policy-agent#214
tsandall added a commit that referenced this issue Aug 29, 2017
The new version of mna/pigeon fixes the location bug that prevented
accurate line/column numbers from being reported on unmatched input.

In the future we can investigate improvements to the error messages by
adding negative matches that return higher-level errors as long as the
location information is not impacted.

Fixes #214
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant