From 4dca8b3e619a321de36b99b6b514d9c01ef76e5e Mon Sep 17 00:00:00 2001 From: Joe Tsai Date: Tue, 10 Feb 2026 11:34:35 -0800 Subject: encoding/json/v2: dual support errors.ErrUnsupported and SkipFunc This change supports both errors.ErrUnsupported and SkipFunc. In a future change, we will remove SkipFunc entirely in favor of using errors.ErrUnsupported, which exists for a similar pupose. Updates #74324 Change-Id: I5f1ada8e3914513d7d23c504f5965ca8dd95ad18 Reviewed-on: https://go-review.googlesource.com/c/go/+/745040 LUCI-TryBot-Result: Go LUCI Reviewed-by: Damien Neil Reviewed-by: Junyang Shao Reviewed-by: Johan Brandhorst-Satzkorn --- src/encoding/json/v2/errors.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/encoding/json/v2/errors.go') diff --git a/src/encoding/json/v2/errors.go b/src/encoding/json/v2/errors.go index 4895386fe2..da50bc30fc 100644 --- a/src/encoding/json/v2/errors.go +++ b/src/encoding/json/v2/errors.go @@ -299,6 +299,13 @@ func collapseSemanticErrors(err error) error { return err } +func wrapErrUnsupported(err error, what string) error { + if errors.Is(err, errors.ErrUnsupported) { + return errors.New(what + " may not return errors.ErrUnsupported") + } + return err +} + // errorModalVerb is a modal verb like "cannot" or "unable to". // // Once per process, Hyrum-proof the error message by deliberately -- cgit v1.3