Remove unreachable err cases from HandleJSONErr

json.UnmarshalError happens only when we pass a non-nil pointer, which
is not the case for us. Usage of go vet helps us make sure it also
won't be happening in the future.
This commit is contained in:
gezimbll
2023-10-26 05:24:04 -04:00
committed by Dan Christian Bogos
parent 9df5f2e02e
commit 16a9c7033f
2 changed files with 0 additions and 17 deletions

View File

@@ -270,10 +270,6 @@ func (rjr *RjReader) HandleJSONError(err error) error {
switch realErr := err.(type) {
case nil:
return nil
case *json.InvalidUTF8Error, *json.UnmarshalFieldError: // deprecated
return err
case *json.InvalidUnmarshalError: // e.g. nil parameter
return err
case *json.SyntaxError:
offset = realErr.Offset
case *json.UnmarshalTypeError:

View File

@@ -312,19 +312,6 @@ func TestHandleJSONErrorInvalidUTF8(t *testing.T) {
}
}
func TestHandleJSONErrorInvalidUnmarshalError(t *testing.T) {
rjr := NewRjReaderFromBytes([]byte("{}"))
err := json.NewDecoder(rjr).Decode(nil)
if err == nil {
t.Fatal(err)
}
err = rjr.HandleJSONError(err)
expectedErr := &json.InvalidUnmarshalError{Type: reflect.TypeOf(nil)}
if err == nil || err.Error() != expectedErr.Error() {
t.Errorf("Expected %+v, received %+v", expectedErr, err)
}
}
func TestHandleJSONErrorDefaultError(t *testing.T) {
rjr := NewRjReaderFromBytes([]byte("{}"))
rjr.indx = 10