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.
This PR adds a typed
IteratorError
which enables consumers to check against jsonitor iterator errors viaerrors.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 forjson.SyntaxError
s 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 toerror
interface with the same message syntax as prior to this change.