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 <dneil@google.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
This commit is contained in:
Damien Neil 2020-09-14 21:00:52 +00:00
parent a408139bb0
commit 114719e16e
4 changed files with 1 additions and 84 deletions

View file

@ -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)
}
}