Open kobi2187 opened 7 years ago
another way is to "lint" it. For example, rethinkdb does sth like this:
Database 'my_db' does not exist
r.db('my_db').table('my table');
^^^^^^^^^^^^^
So it uses the symbol ^
to point out the erroneous portion. But it could be challenging to deal with line breaks if the source is long.
yet another way is to show the drilled path like "data[0].id" should be Int
I'm not sure just how far I want to go with this. The library is built with speed in mind, so there are limits to just how much context we can carry around. That said just creating errors at lexeme level and throwing them in the user's face with just the single character source is way too brutal. There's certainly enough information at compile time to get something like String literal expected but found <actualExpr>
using skipValue
to extract actualExpr
and using the whole skipped expression's position to report the error. Or something.
When I supplied a typedef with wrong types, to be the parsing result for Json.parse function I got the following exception.
An example for a better error message can be:
Thanks!