clp-s: Report exactly where parsing error occurs when parsing JSON (fixes #514). #503
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR adds reporting for where a parsing error occurs within a JSON file, and fixes an issue where parsing exceptions were sometimes not caught.
We add some code to the main parsing loop to keep track of how many bytes from the current file have been consumed up to the previous record. When an error occurs we are then able to report how many bytes were parsed successfully .
We also wrap the main "parse_line" function in a try/catch block. Even after getting a valid iterator to a record it seems that certain kinds of invalid fields can throw latent errors in simdjson, which previously went uncaught. Instead of trying to add error handling for every single time we access a field within parse_line we just catch the thrown errors.
Validation performed