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

Add more context to type errors #952

Open
ayuhito opened this issue May 17, 2024 · 1 comment
Open

Add more context to type errors #952

ayuhito opened this issue May 17, 2024 · 1 comment
Labels
feature Issue asking for a new feature in go-toml.

Comments

@ayuhito
Copy link

ayuhito commented May 17, 2024

Describe the issue
The current error types returned are almost enough context to create a pretty-error wrapper, but not quite everything needed.

For example, StrictMissingError returns enough context to generate an error message like this:

image

However, the generic DecodeError struct, which appears for type errors, lacks additional functions to identify which key doesn't match what type, making it difficult to build a pretty-error wrapper around it.

image

Currently, the solution I have implemented produces the above output, but it is not very user-friendly. Adding more context to the DecodeError struct, such as type information and the specific key responsible, would be really helpful. Additionally, I think there is a bug where DecodeError.Key() returns an empty list for this, making it impossible to programmatically name the responsible key.

Thank you for the awesome library!

@pelletier
Copy link
Owner

Thank you for filing this issue! I think indeed the DecodeErrors should be improved to provide that context!

@pelletier pelletier added the feature Issue asking for a new feature in go-toml. label Aug 17, 2024
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