Skip to content

Improve error messages resulting from bad "operation prototype strings", etc. #43

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

Open
alexwarth opened this issue Sep 22, 2015 · 0 comments

Comments

@alexwarth
Copy link
Contributor

Right now if you specify an invalid operation prototype string when you add an operation to a semantics, e.g.,

MyGrammar.semantics().addOperation('myOperation(x, y', {...})

you'll get a generic Ohm error message like this:

> 1 | myOperation(x, y
                      ^
Expected ")"

which is not very nice.

A couple of things that would make it better:

(1) Give a little context before showing the snippet of the input and the failures / expectations
(2) Don't include a line number

E.g.,

Invalid operation prototype string:

  myOperation(x, y
                  ^
Expected ")"

(Thing (2) suggests that we should have a better API for getting messages out of a MatchFailure. At the moment you can either get a one-size-fits-all message via the message property, or build your own using the getRightmostFailures() method. It would be nice to add a getMessage method that lets you specify some options, e.g., mf.getMessage({includeLineNumbers: false, includeFluffyFailures: true, ...}).)

@pdubroy pdubroy added the uw label Oct 24, 2016
@pdubroy pdubroy removed the uw label Sep 17, 2022
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