Parsing errors are not user-friendly
preciselytom opened this issue · 1 comments
preciselytom commented
Our app allows end users (not developers) to write mathematical expressions. We would like to present errors in a way that the users will understand. Unfortunately, the parser errors are very low-level and not related to the mathematical syntax.
Examples of actual and desired output:
Input:
Actual error: unexpected EOF while scanning extensions
Desired error: input is empty
Input: (
Actual error: unexpected EOF while scanning extensions
Desired error: missing right parenthesis
Input: )
Actual error: unexpected ")" while scanning extensions
Desired error: missing left parenthesis
Input: ()
Actual error: unexpected ")" while scanning extensions
Desired error: no expression inside parentheses
Input: 1+
Actual error: unexpected EOF while scanning extensions
Desired error: missing expression to the right of "+"
Input: +1
Actual error: unexpected "+" while scanning extensions
Desired error: missing expression to the left of "+"
generikvault commented
Yes better errors would be great.
It's pretty hard to implement them inside a framework as generell as gval.
If you have a solution thats general enough to work with the generic approach, feel free to make a pull request
Maybe it's easier to make a post check if an error occurs. Run a few RegExp and replace the error message if it matchs the expression?