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
This commit is contained in:
Wilfred Asomani 2023-05-03 17:07:11 +00:00 committed by Storj Robot
parent 8b82dba602
commit 4ab433ba89
2 changed files with 5 additions and 2 deletions

View File

@ -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 { err = s.store.WithTx(ctx, func(ctx context.Context, tx DBTx) error {
for _, user := range users { for _, user := range users {
if _, err := tx.ProjectMembers().Insert(ctx, user.ID, isMember.project.ID); err != nil { 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 return err
} }
} }

View File

@ -212,8 +212,8 @@ async function onAddUsersClick(): Promise<void> {
try { try {
await pmStore.addProjectMembers(emailArray, projectsStore.state.selectedProject.id); await pmStore.addProjectMembers(emailArray, projectsStore.state.selectedProject.id);
} catch (error) { } catch (_) {
await notify.error(`Error during adding project members. ${error.message}`, AnalyticsErrorEventSource.ADD_PROJECT_MEMBER_MODAL); await notify.error(`Error during adding project members.`, AnalyticsErrorEventSource.ADD_PROJECT_MEMBER_MODAL);
isLoading.value = false; isLoading.value = false;
return; return;