From 4ab433ba8952921cb2f14ce4603cd2d28bac1ce2 Mon Sep 17 00:00:00 2001 From: Wilfred Asomani Date: Wed, 3 May 2023 17:07:11 +0000 Subject: [PATCH] satellite/{web,console}: make duplicate member error readable This change makes the error thrown when adding an existing member to a project readable. Issue: https://github.com/storj/storj/issues/5840 Change-Id: I4269495f9b7b09c77fbf1af1fc605e5c95bd7cbf --- satellite/console/service.go | 3 +++ web/satellite/src/components/modals/AddTeamMemberModal.vue | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/satellite/console/service.go b/satellite/console/service.go index efbaeb1c8..56c1a84e0 100644 --- a/satellite/console/service.go +++ b/satellite/console/service.go @@ -1965,6 +1965,9 @@ func (s *Service) AddProjectMembers(ctx context.Context, projectID uuid.UUID, em err = s.store.WithTx(ctx, func(ctx context.Context, tx DBTx) error { for _, user := range users { if _, err := tx.ProjectMembers().Insert(ctx, user.ID, isMember.project.ID); err != nil { + if strings.Contains(err.Error(), "duplicate key") { + return errs.New("%s is already on the project", user.Email) + } return err } } diff --git a/web/satellite/src/components/modals/AddTeamMemberModal.vue b/web/satellite/src/components/modals/AddTeamMemberModal.vue index 1b896b21a..38b7d3619 100644 --- a/web/satellite/src/components/modals/AddTeamMemberModal.vue +++ b/web/satellite/src/components/modals/AddTeamMemberModal.vue @@ -212,8 +212,8 @@ async function onAddUsersClick(): Promise { try { await pmStore.addProjectMembers(emailArray, projectsStore.state.selectedProject.id); - } catch (error) { - await notify.error(`Error during adding project members. ${error.message}`, AnalyticsErrorEventSource.ADD_PROJECT_MEMBER_MODAL); + } catch (_) { + await notify.error(`Error during adding project members.`, AnalyticsErrorEventSource.ADD_PROJECT_MEMBER_MODAL); isLoading.value = false; return;