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

Include duplicate key name in ValueOverwriteError error message #60

Closed
rsim opened this issue May 12, 2015 · 3 comments
Closed

Include duplicate key name in ValueOverwriteError error message #60

rsim opened this issue May 12, 2015 · 3 comments

Comments

@rsim
Copy link
Contributor

rsim commented May 12, 2015

Currently if value is assigned to the same key then ValueOverwriteError error is raised without any error message:

>> TOML.parse "a = 1\na = 2"
TOML::ValueOverwriteError: TOML::ValueOverwriteError

When parsing long TOML files it would be better to include more information in the error message so that the duplicate key could be located. As I see in https://github.com/emancu/toml-rb/blob/master/lib/toml/keyvalue.rb#L13 at least key could be included in the error message.

@fbernier
Copy link

I am not sure the example you provided should raise an error. I can't find any reference to it in the spec, and json does not raise an error either:

JSON.parse('{"a": 1, "a": 2}')
=> {"a"=>2}

@rsim
Copy link
Contributor Author

rsim commented May 13, 2015

TOML spec states that

You cannot define any key or table more than once.

@fbernier
Copy link

Cool thanks I'll fix my own parser then

@emancu emancu closed this as completed May 13, 2015
emancu added a commit that referenced this issue May 13, 2015
Closed issues #60 and #59
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