mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-15 21:29:52 +05:00
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:
committed by
Dan Christian Bogos
parent
9df5f2e02e
commit
16a9c7033f
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user