Skip to content

Commit

Permalink
[CORE-1513] Correct project-already-exists error message (#8628)
Browse files Browse the repository at this point in the history
* Correct project-already-exists error message

Turns out that the error message came from the collection package and
indicated that the item in the “projects” table already existed.
  • Loading branch information
robert-uhl committed Mar 8, 2023
1 parent a8da5cc commit 9af9c7e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/server/pfs/pfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func (e ErrProjectNotFound) GRPCStatus() *status.Status {
}

func (e ErrProjectExists) Error() string {
return fmt.Sprintf("project %q already exists", e.Project.Name)
return fmt.Sprintf("project %s already exists", e.Project.Name)
}

func (e ErrProjectExists) GRPCStatus() *status.Status {
Expand Down
12 changes: 10 additions & 2 deletions src/server/pfs/server/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,10 +488,18 @@ func (d *driver) createProject(ctx context.Context, req *pfs.CreateProjectReques
} else if !errors.Is(err, auth.ErrNotActivated) {
return errors.Wrap(err, "could not get caller's username")
}
return errors.EnsureStack(projects.Create(pfsdb.ProjectKey(req.Project), &pfs.ProjectInfo{
if err := projects.Create(pfsdb.ProjectKey(req.Project), &pfs.ProjectInfo{
Project: req.Project,
Description: req.Description,
}))
}); err != nil {
if errors.As(err, &col.ErrExists{}) {
return pfsserver.ErrProjectExists{
Project: req.Project,
}
}
return errors.Wrap(err, "could not create project")
}
return nil
})
}

Expand Down

0 comments on commit 9af9c7e

Please sign in to comment.