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

Verbose error type implementation #901

Closed
Geal opened this issue Apr 6, 2019 · 1 comment
Closed

Verbose error type implementation #901

Geal opened this issue Apr 6, 2019 · 1 comment
Milestone

Comments

@Geal
Copy link
Collaborator

Geal commented Apr 6, 2019

nom should provide a good verbose error type to replace the one from the verbose-errors feature. I started an example in https://github.com/Geal/nom/blob/5.0/examples/json.rs
The code should be extracted from the example and put into nom.
Some questions on how to handle it:

  • how can we implement ParseError::or? This is used in alt, to compare or accumulate errors from different branches. I tried the error accumulation and I'm not convinced it's useful (most error branches will be useless). A better solution would be to compare the input position in various errors and keep the error that went the furthest into the input (it has the best chance to be the "correct" error)
  • I'd like to add a ParseError::from_tag method, to have the ability to write "expected tag 'xyz', found 'abc'". The issue is that we do not have any info on the lifetime of tags. I'm wary of introducing a lifetime in VerboseError. Should we mandate 'static on the tag? Or Clone?
  • in the same way, I'd like to construct errors from is_a and is_not, and show the expected chars in the errors, and I think it will have the samelifetime issues as tag
  • I wrote the example assuming the input type &str, which allows constructing a useful error message in convert_error. What would such an error message look like if the input is &[u8]? If it is &[u8] but we expect ASCII or UTF-8 data (but considering we might not have received valid data)
  • should VerboseError have implementations that work on types that deref to &str or &[u8] instead?
@Geal Geal added this to the 5.0 milestone Apr 6, 2019
@Geal Geal mentioned this issue Apr 6, 2019
22 tasks
@Geal
Copy link
Collaborator Author

Geal commented Apr 10, 2019

the error type from the example is now integrated in ea87cdf. VerboseError is now generic over the input type, but now there's an issue with implementing or properly. convert_error can be specialized over the input type. Still no idea how to implement ParseError::from_tag

@Geal Geal closed this as completed May 25, 2019
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

No branches or pull requests

1 participant