nilnesserr failed to detect this problem, while correcterr did (I guess, because there's no way to know for sure that err there would be nil):
newInsertedPhotos, err := db.InsertPhotosTx(ctx, tx, photosToInsert)
if err != nil {
return nil, errors.Wrap(err, "insert photos failed")
}
/**/
for _, currentPhoto := range photosCurrentState {
/**/
if !isFound {
/**/
updPhotoStatusQuery, errU := db.prepareUpdatePhotoStatusQuery(photoEntityFilter, review_admin.PhotoStatusDeletedByClient)
if errU != nil {
return nil, errU
}
if _, err = tx.Execx(
wrapCtxWithName(ctx, "update_photo_status"),
updPhotoStatusQuery,
); err != nil {
return nil, errors.Wrap(err, "update photo failed")
}
/**/
}
/**/
}
/**/
errUpdateItemMeta := db.UpsertPublishedMediaCount(ctx, tx, &UpsertMediaCountSpec{/**/})
if errUpdateItemMeta != nil {
return nil, fmt.Errorf("db.upsertPublishedMediaCount: %w", err) // <-------------------------- wrong!
}
Originally posted by @m-ocean-it in m-ocean-it/correcterr#2 (comment)
nilnesserrfailed to detect this problem, whilecorrecterrdid (I guess, because there's no way to know for sure thaterrthere would benil):Originally posted by @m-ocean-it in m-ocean-it/correcterr#2 (comment)