-
Notifications
You must be signed in to change notification settings - Fork 12
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
Implement a new error strategy for simplifying error messages #529
Conversation
Coverage tests results394 tests ±0 357 ✅ ±0 4s ⏱️ ±0s For more details on these failures, see this check. Results for commit da25f59. ± Comparison against base commit 3df786c. ♻️ This comment has been updated with latest results. |
d034f61
to
5a97bcc
Compare
…so that we can have useful errors - May also be useful for customers down the line.
5a97bcc
to
da25f59
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this definitely makes errors more digestible. few nits to make it a bit more idiomatic.
msg.append(" was unexpected ") | ||
msg.append(generateMessage(recognizer, e)) | ||
msg.append("\nexpecting one of: ") | ||
msg.append(buildExpectedMessage(recognizer, e.getExpectedTokens)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use interpolated stings: val msg = s"${getTokenErrorDisplay(e.getOffendingToken)} was unexpected ..."
- more readable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will. do - @vil1 also suggested the same
val stack = e.getStackTrace | ||
stack.foreach { traceElement => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val stack = e.getStackTrace | |
stack.foreach { traceElement => | |
val messages = e.getStackTrace.flatMap { traceElement => ... |
flatMap would be more idiomatic here.
* @return | ||
* the expected string with tokens renamed in more human friendly form | ||
*/ | ||
import scala.collection.mutable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you move the import to the top?
Here we implement a new error strategy for constructing error messages such that they are actually useful instead of listing out 780 possible tokens that were expected.