From 114719e16e9681bd1001326598ededa719c17944 Mon Sep 17 00:00:00 2001 From: Damien Neil Date: Mon, 14 Sep 2020 21:00:52 +0000 Subject: Revert "encoding/json: implement Is on all errors" This reverts CL 254537. Reason for revert: Reason for revert: The recommended way to check for a type of error is errors.As. API changes should also start with a proposal. Change-Id: I07c37428575e99c80b17525833a61831d10963bb Reviewed-on: https://go-review.googlesource.com/c/go/+/254857 Trust: Damien Neil Reviewed-by: Emmanuel Odeke --- src/encoding/json/decode_test.go | 31 ------------------------------- 1 file changed, 31 deletions(-) (limited to 'src/encoding/json/decode_test.go') diff --git a/src/encoding/json/decode_test.go b/src/encoding/json/decode_test.go index b707dcfa99..219e845c7b 100644 --- a/src/encoding/json/decode_test.go +++ b/src/encoding/json/decode_test.go @@ -2572,34 +2572,3 @@ func TestUnmarshalMaxDepth(t *testing.T) { } } } - -func TestInvalidUnmarshalErrorIs(t *testing.T) { - err := fmt.Errorf("apackage: %w: failed to parse struct", &InvalidUnmarshalError{reflect.TypeOf("a")}) - if !errors.Is(err, &InvalidUnmarshalError{}) { - t.Fatalf("%v should be unwrapped to a InvalidUnmarshalError", err) - } -} - -func TestUnmarshalFieldErrorIs(t *testing.T) { - err := fmt.Errorf("apackage: %w: failed to parse struct", &UnmarshalFieldError{ - Key: "foo", - Type: reflect.TypeOf("a"), - Field: reflect.StructField{Name: "b"}, - }) - if !errors.Is(err, &UnmarshalFieldError{}) { - t.Fatalf("%v should be unwrapped to a UnmarshalFieldError", err) - } -} - -func TestUnmarshalTypeErrorIs(t *testing.T) { - err := fmt.Errorf("apackage: %w: failed to parse struct", &UnmarshalTypeError{ - Value: "foo", - Type: reflect.TypeOf("a"), - Offset: 1, - Struct: "Foo", - Field: "Bar", - }) - if !errors.Is(err, &UnmarshalTypeError{}) { - t.Fatalf("%v should be unwrapped to a UnmarshalTypeError", err) - } -} -- cgit v1.3