From 26b6463bd6f72338d58872f4570b0acd5a985ec7 Mon Sep 17 00:00:00 2001 From: Michael Mandrus Date: Wed, 30 Nov 2022 10:56:44 -0500 Subject: [PATCH] make create call consistent with update and delete --- pkg/services/publicdashboards/service/service.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/services/publicdashboards/service/service.go b/pkg/services/publicdashboards/service/service.go index daab65439bd..889336479ae 100644 --- a/pkg/services/publicdashboards/service/service.go +++ b/pkg/services/publicdashboards/service/service.go @@ -168,11 +168,15 @@ 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) } + if affectedRows == 0 { + return nil, ErrPublicDashboardNotFound.Errorf("Create: failed to create a public dashboard with Uid: %s", uid) + } + //Get latest public dashboard to return newPubdash, err := pd.store.Find(ctx, uid) if err != nil {