Skip to content

Add more context to type errors #952

@ayuhito

Description

@ayuhito

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureIssue asking for a new feature in go-toml.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions