From 96a185e0acb6c76b2556ee5f2d7946346ce8124c Mon Sep 17 00:00:00 2001 From: nourbalaha Date: Mon, 21 Oct 2024 11:50:14 +0900 Subject: [PATCH] add ErrNoUsersSpecified error handling --- account/accountusecase/accountinteractor/workspace.go | 4 ++++ account/accountusecase/accountinterfaces/common.go | 1 + 2 files changed, 5 insertions(+) diff --git a/account/accountusecase/accountinteractor/workspace.go b/account/accountusecase/accountinteractor/workspace.go index 6822526..288a6a3 100644 --- a/account/accountusecase/accountinteractor/workspace.go +++ b/account/accountusecase/accountinteractor/workspace.go @@ -232,6 +232,10 @@ func (i *Workspace) RemoveMultipleUserMembers(ctx context.Context, id workspace. return nil, accountinterfaces.ErrInvalidOperator } + if userIds.Len() == 0 { + return nil, accountinterfaces.ErrNoUsersSpecified + } + return Run1(ctx, operator, i.repos, Usecase().Transaction(), func(ctx context.Context) (*workspace.Workspace, error) { ws, err := i.repos.Workspace.FindByID(ctx, id) if err != nil { diff --git a/account/accountusecase/accountinterfaces/common.go b/account/accountusecase/accountinterfaces/common.go index 3f780f2..905352f 100644 --- a/account/accountusecase/accountinterfaces/common.go +++ b/account/accountusecase/accountinterfaces/common.go @@ -8,4 +8,5 @@ import ( var ( ErrOperationDenied error = rerror.NewE(i18n.T("operation denied")) ErrInvalidOperator error = rerror.NewE(i18n.T("invalid operator")) + ErrNoUsersSpecified error = rerror.NewE(i18n.T("no users specified for removal")) )