Include duplicate key name in ValueOverwriteError error message
Closed this issue · 3 comments
rsim commented
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 commented
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}
fbernier commented
Cool thanks I'll fix my own parser then