Skip to content

misleading error message #352

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
fmoor opened this issue Aug 31, 2017 · 5 comments
Closed

misleading error message #352

fmoor opened this issue Aug 31, 2017 · 5 comments

Comments

@fmoor
Copy link
Contributor

fmoor commented Aug 31, 2017

I was going through the serde_json :: de :: from_reader example and encountered an error at run time "KeyMustBeAString". I went back to my json file and looked. All of the keys were strings... I scratched my head and stared. Then I noticed that I had a trailing comma after the last value.

It seems like adding another error code that has something to do with trailing commas would make the error messages more human friendly.

test.json

{
  "fingerprint": "gray",
  "location": "1",
}

error message:

ErrorImpl { 
    code: KeyMustBeAString,
    line: 4,
    column: 1
 }
@dtolnay
Copy link
Member

dtolnay commented Aug 31, 2017

I agree! Would you be interested in implementing this? The code for parsing a map key will need to recognize when it gets a } and treat that as a trailing comma error.

@fmoor
Copy link
Contributor Author

fmoor commented Aug 31, 2017

I'll give it a go.

@fmoor
Copy link
Contributor Author

fmoor commented Aug 31, 2017

Is there documentation on contributing? It seems like the tests don't compile on rustc stable...

@fmoor
Copy link
Contributor Author

fmoor commented Aug 31, 2017

I switched to nightly and the tests compile with warnings about unused extern crate. Only a hand full of tests run and they all fail. What gives?

rustc 1.21.0-nightly (7eeac1b81 2017-08-30)
cargo 0.22.0-nightly (3d3f2c05d 2017-08-27)

@fmoor
Copy link
Contributor Author

fmoor commented Aug 31, 2017

Further study of travis.sh revealed that I was missing a build step

(cd "$DIR/tests/deps" && channel build)

All tests seem to be passing. On to the real work.

fmoor added a commit to fmoor/json that referenced this issue Sep 1, 2017
@dtolnay dtolnay closed this as completed in 4afb61c Sep 9, 2017
dtolnay added a commit that referenced this issue Sep 9, 2017
change error type for trailing commas, fixes #352
# for free to join this conversation on GitHub. Already have an account? # to comment
Development

No branches or pull requests

2 participants