rob05c commented on a change in pull request #4942:
URL: https://github.com/apache/trafficcontrol/pull/4942#discussion_r485164807
##########
File path: traffic_ops/traffic_ops_golang/api/generic_crud.go
##########
@@ -223,7 +225,15 @@ func GenericRead(h http.Header, val GenericReader, useIMS
bool) ([]interface{},
}
// GenericUpdate handles the common update case, where the update returns the
new last_modified time.
-func GenericUpdate(val GenericUpdater) (error, error, int) {
+func GenericUpdate(h http.Header, val GenericUpdater) (error, error, int) {
+ existingLastUpdated, err := val.GetLastUpdated()
+ if err != nil {
+ return errors.New("no " + val.GetType() + " found with this
id"), err, http.StatusNotFound
Review comment:
This could be a real database error. As above, I think we should change
it to `func GetLastUpdated(tx *sqlx.Tx, ID int, tableName string) (time.Time,
bool, error)` and handle both here,
```
existingLastUpdated, ok, err := val.GetLastUpdated()
if !ok {
return errors.New("no " + val.GetType() + " found with this
id"), nil, http.StatusNotFound
} else if err != nil {
return nil, errors.New(nil, errors.New("getting " +
val.GetType() + " last updated: " + err.Error()), http.StatusInternalServerError
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]