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

Avoid recording JSON kind in unmarshal errors before next token #76

Merged
merged 1 commit into from
Dec 19, 2024

Conversation

dsnet
Copy link
Collaborator

@dsnet dsnet commented Dec 19, 2024

Every caller of newUnmarshalErrorBefore is for the case where the Go type has some problem and cannot be unmarshaled into. In such a case, recording the upcoming JSON kind is a red herring since it is information that is not directly relevant to the problem.

Every caller of newUnmarshalErrorBefore is for the case where
the Go type has some problem and cannot be unmarshaled into.
In such a case, recording the upcoming JSON kind is a red herring
since it is information that is not directly relevant to the problem.
@dsnet
Copy link
Collaborator Author

dsnet commented Dec 19, 2024

Before it would print:

cannot unmarshal JSON string into Go string within "/String": invalid format flag "invalid"

now it just prints:

cannot unmarshal into Go string within "/String": invalid format flag "invalid"

which is more clear about what the problem is.

More information in an error is not always a good thing.

Copy link
Collaborator

@johanbrandhorst johanbrandhorst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@dsnet dsnet merged commit cad2278 into master Dec 19, 2024
8 checks passed
@dsnet dsnet deleted the unmarshal-errors-before branch December 20, 2024 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants