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 typed IteratorError #685

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

btnmasher
Copy link

@btnmasher btnmasher commented Aug 30, 2023

This PR adds a typed IteratorError which enables consumers to check against jsonitor iterator errors via errors.As (directly or if the error itself is wrapped), as well as provide the additional context fields about the error to use in formatting their error messages in their preferred fashion.

This functionality is roughly comparable to stdlib's json.SyntaxError, which jsonitor does not currently have an equivalent. This has caused some headaches with my use of gin and it's JSON Binding mechanisms with gin's build tags set to supplant the stdlib json parser with jsonitor. Error reporting mechanisms which check for json.SyntaxErrors to aid in formatting user-presentable, helpful error messages in my APIs cannot easily detect jsonitor's iterator error messages because until this PR the error messages were untyped, generic error strings.

This change should be a transparent to existing consumers as the IteratorError type conforms to error interface with the same message syntax as prior to this change.

@btnmasher btnmasher closed this Aug 30, 2023
@btnmasher btnmasher reopened this Aug 30, 2023
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.

1 participant