-
-
Notifications
You must be signed in to change notification settings - Fork 120
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
Range in characters is sub-optimal for error reporting to humans #67
Comments
That sounds like a good idea, and a PR would indeed be welcome. This may need to expose two different APIs, e.g. something like Things to be aware of:
|
Ok thanks. I'm making some progress, able to build up a list of line offsets at the same point the Will PR as soon as I have a tested solution. Please consider me working on this issue. |
Do keep in mind that adding a cost for each parser run might overall not be worth it, as it's relatively rare that you'll encounter an error, and then want to display it to a human in a friendly manner. At that point we've already failed, and spending a few extra cycles might make more sense than doing something on every run of the parser. |
Ok, just to clarify, you mean it's only worth computing the line offsets and doing the conversion when explicitly asked for (i.e. the caller can re-parse the document(s) with some option flag turned on or parse at a lower level)? In my use case (an OpenAPI validator and linter) errors are commonly encountered and almost expected, though I accept this may be an outlier. |
Correct. The parser doesn't otherwise need to track newlines, so we should not require that it does so every time. However, as you may get multiple errors from a single input document, it may well make sense to cache the positions of newlines when they're first determined. |
Thanks. Will put the calculation behind an option. |
Could you let me know how |
Drat, sorry, should add developer guidelines with that info. There's a git submodule that you need. Run this in the project root:
|
Perfect, thanks. Worked once I cleared out the basic clone I'd done into that directory. |
I don't know what's up with that error. That commit definitely exists. |
Ignore that, I had a clone of YAML-test-suite in that directory I forgot to remove. |
Let me know if you want a PR for this, and if so, against |
As YAML is line-delimited (can't be strung together minified like JSON) it makes at least some sense to be able to report errors (both syntactically and semantically) as a line number and column number pair.
Is it simple to add a helper routine to achieve this? Happy to PR with a bit of pointing in the right direction.
My end use-case is to turn JSON pointer references to schema violations back into line number, column number pairs.
The text was updated successfully, but these errors were encountered: