return function return value when is only err

This commit is contained in:
Sam Woodard 2018-10-16 07:33:23 -07:00
parent 9246c912f5
commit 6bf44faa3c
2 changed files with 4 additions and 17 deletions

View File

@ -12,10 +12,7 @@ import (
// http://jsonapi.org/format/#document-top-level // http://jsonapi.org/format/#document-top-level
// and here: http://jsonapi.org/format/#error-objects. // and here: http://jsonapi.org/format/#error-objects.
func MarshalErrors(w io.Writer, errorObjects []*ErrorObject) error { func MarshalErrors(w io.Writer, errorObjects []*ErrorObject) error {
if err := json.NewEncoder(w).Encode(&ErrorsPayload{Errors: errorObjects}); err != nil { return json.NewEncoder(w).Encode(&ErrorsPayload{Errors: errorObjects})
return err
}
return nil
} }
// ErrorsPayload is a serializer struct for representing a valid JSON API errors payload. // ErrorsPayload is a serializer struct for representing a valid JSON API errors payload.

View File

@ -68,10 +68,7 @@ func MarshalPayload(w io.Writer, models interface{}) error {
return err return err
} }
if err := json.NewEncoder(w).Encode(payload); err != nil { return json.NewEncoder(w).Encode(payload)
return err
}
return nil
} }
// Marshal does the same as MarshalPayload except it just returns the payload // Marshal does the same as MarshalPayload except it just returns the payload
@ -128,10 +125,7 @@ func MarshalPayloadWithoutIncluded(w io.Writer, model interface{}) error {
} }
payload.clearIncluded() payload.clearIncluded()
if err := json.NewEncoder(w).Encode(payload); err != nil { return json.NewEncoder(w).Encode(payload)
return err
}
return nil
} }
// marshalOne does the same as MarshalOnePayload except it just returns the // marshalOne does the same as MarshalOnePayload except it just returns the
@ -195,11 +189,7 @@ func MarshalOnePayloadEmbedded(w io.Writer, model interface{}) error {
payload := &OnePayload{Data: rootNode} payload := &OnePayload{Data: rootNode}
if err := json.NewEncoder(w).Encode(payload); err != nil { return json.NewEncoder(w).Encode(payload)
return err
}
return nil
} }
func visitModelNode(model interface{}, included *map[string]*Node, func visitModelNode(model interface{}, included *map[string]*Node,