go-toml icon indicating copy to clipboard operation
go-toml copied to clipboard

Add more context to type errors

Open ayuhito opened this issue 9 months ago • 1 comments

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!

ayuhito avatar May 17 '24 14:05 ayuhito