Skip to content

Possible improvement: nilnesserr failed to detect this problem, while correcterr #19

@ccoVeille

Description

@ccoVeille

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions