-
-
Notifications
You must be signed in to change notification settings - Fork 190
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
More information in errors #290
Comments
When constructing a parser, Participle will return the stack of types leading up to the failed structure. It doesn't currently narrow it down to the field though. eg. https://go.dev/play/p/zvJv_w4YfJx gives
I think in this case it's just missing the inner struct in the trace. |
Sorry, that comment was misleading, and actually wasn't what I was talking about. What I'm referring to is using a correct and working parser definition to parse a file where the contents are an incomplete string: https://go.dev/play/p/bVqcFvYlHkT |
Ah I see. In that case you want the |
Also, in the case of partial failure, the returned structure will be populated up to the point of the last successful match. I've found this useful. This is covered in the docs BTW. |
Here's an example of what I mean: https://go.dev/play/p/MB73BT2KR8D
|
I would really like the ability to introspect more into the parser's state when it fails in order to generate better error messages.
For example, if I have a String grammar that looks something like
if I leave off the final
"
the error I get isunexpected token "<EOF>" (expected "\"")
and there appears to be no way of looking at a partial parse state to find where the first"
was. I'd love if the parser could somehow return a stack of incomplete productions that could be inspected from the returned error. Or even better, let a production include aError participle.Error
field, which if not-nil signifies that the enclosing production is incomplete somehow, and then it would be returned from.Parse
instead of an empty value.The text was updated successfully, but these errors were encountered: