Skip to content
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

confusing error message for wrong variable type. #8

Open
kobi2187 opened this issue Jan 17, 2017 · 2 comments
Open

confusing error message for wrong variable type. #8

kobi2187 opened this issue Jan 17, 2017 · 2 comments

Comments

@kobi2187
Copy link

kobi2187 commented Jan 17, 2017

When I supplied a typedef with wrong types, to be the parsing result for Json.parse function
I got the following exception.

Uncaught exception - Error#422: 
Expected " at character 30 in ... :true,"data":[{"id": ----> 9 <---- 225,"creator_user_id ... @ tink.json.BasicParser.die:237

An example for a better error message can be:

IN array 'data', item's field 'id:String' should be 'id:Int' to match '9' 
line was:  .....

Thanks!

@kevinresol
Copy link
Member

kevinresol commented Jan 17, 2017

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

@back2dos
Copy link
Member

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.

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

3 participants