kach / nearley

📜🔜🌲 Simple, fast, powerful parser toolkit for JavaScript.
https://nearley.js.org
MIT License
3.57k stars 231 forks source link

Provide a way for users to format their own error messages #633

Open agladysh opened 1 year ago

agladysh commented 1 year ago

Current implementation produces error message of hundreds of lines for larger grammars.

Ideally as a nearley user I would be able to format the error message myself from the data on the Error object.

One option to do that could be to add all necessary data as fields on the Error object, and add .toString() to it, formatting the error message as it is done now.