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

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

Open
bep opened this issue Aug 17, 2022 · 1 comment
Open

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

bep opened this issue Aug 17, 2022 · 1 comment
Labels
feature Issue asking for a new feature in go-toml.

Comments

@bep
Copy link

bep commented Aug 17, 2022

This relates to the bug fixed in 7baa23f

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 pelletier added the feature Issue asking for a new feature in go-toml. label Aug 21, 2022
@pelletier
Copy link
Owner

Thanks for the report! Sounds a like a good time to start sprinkling more of

func (d *decoder) typeMismatchError(toml string, target reflect.Type) error {
to return more specific errors.

jidicula added a commit to jidicula/go-toml that referenced this issue Oct 27, 2022
Uses the existing method to DRY up the error message generation, and decorates
with position index where needed. No behaviour is changed, but it allows for
further changes to make error messaging more specific.

Related to: pelletier#806
pelletier pushed a commit that referenced this issue Oct 30, 2022
Uses the existing method to DRY up the error message generation, and decorates
with position index where needed. No behaviour is changed, but it allows for
further changes to make error messaging more specific.

Related to: #806
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Issue asking for a new feature in go-toml.
Projects
None yet
Development

No branches or pull requests

2 participants