Pubdash: Verify affected rows count in database 'create' call (#59591)

* make create call consistent with update and delete

* use appropriate error type

* update log statements

* update error log for 0 affected rows
This commit is contained in:
Michael Mandrus 2022-12-02 08:46:35 +01:00 committed by GitHub
parent 7f92f1df00
commit 8152b0e1ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -168,9 +168,11 @@ func (pd *PublicDashboardServiceImpl) Create(ctx context.Context, u *user.Signed
},
}
_, err = pd.store.Create(ctx, cmd)
affectedRows, err := pd.store.Create(ctx, cmd)
if err != nil {
return nil, ErrInternalServerError.Errorf("Create: failed to create the public dashboard: %w", err)
return nil, ErrInternalServerError.Errorf("Create: failed to create the public dashboard with Uid %s: %w", uid, err)
} else if affectedRows == 0 {
return nil, ErrInternalServerError.Errorf("Create: failed to create a database entry for public dashboard with Uid %s. 0 rows changed, no error reported.", uid)
}
//Get latest public dashboard to return