pelletier / go-toml

Go library for the TOML file format
https://github.com/pelletier/go-toml
Other
1.69k stars 206 forks source link

Improve error message for "toml: cannot decode array table into a ..." #806

Open bep opened 2 years ago

bep commented 2 years ago

This relates to the bug fixed in 7baa23f493a82b3f24f4dada5d0b02d17fbde175

Judging by the number of these errors that pops up in my own projects, I suspect that this error message will pop up in enough projects around to warrant a better error message, most notably an error message that includes the container key. That would make it much easier to correct for the end user. In typical configuration scenarios the user does not have much insight into the Go struct.

pelletier commented 2 years ago

Thanks for the report! Sounds a like a good time to start sprinkling more of https://github.com/pelletier/go-toml/blob/7baa23f493a82b3f24f4dada5d0b02d17fbde175/unmarshaler.go#L151 to return more specific errors.