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

error.source.context is often too big to be helpful #96

Closed
isaacs opened this issue Mar 10, 2019 · 3 comments
Closed

error.source.context is often too big to be helpful #96

isaacs opened this issue Mar 10, 2019 · 3 comments

Comments

@isaacs
Copy link
Contributor

isaacs commented Mar 10, 2019

I'm finding myself in a few cases where error.source.context is a pretty large object. Printing this out (with a logger that includes the source text of functions) results in over 15,000 lines of debugging, which is way too much. Node's built-in console.log() is still several hundred lines.

I can see how this is helpful when working on bugs and features in YAML itself, but it's pretty excessive otherwise. Perhaps it could be omitted when cwd is not the YAML project?

@eemeli
Copy link
Owner

eemeli commented Apr 4, 2019

Sorry for having left this issue unanswered before now. The error source is in fact the corresponding CST node, and its context is required by some parsing stages, which will continue even after the point at which the error has occurred. So it's a bit difficult to modify, especially as it's required by the internals of the getRangeAsLinePos getter.

What might work is an optional post-processing of the errors and warnings, which would fetch the errors' line positions and drop most of the CST source node data. Optional, so as not to necessitate a major version bump.

@isaacs
Copy link
Contributor Author

isaacs commented Apr 4, 2019

An optional error/warning cleanup step would probably solve this, yes.

@eemeli
Copy link
Owner

eemeli commented Apr 5, 2019

Added the prettyErrors option (default false), which drops source and adds nodeType, range and linePos to errors.

@eemeli eemeli closed this as completed Apr 5, 2019
eemeli added a commit that referenced this issue Apr 6, 2019
generated from commit f6721ec13df9f1eb97d8f53b79a798b61388d035
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

2 participants