Skip to content

Commit

Permalink
Merge pull request #45 from Killerrekt/master
Browse files Browse the repository at this point in the history
added a extra error code for if name already exists
  • Loading branch information
aditansh committed Mar 15, 2024
2 parents 5ef94ba + 0894bcb commit c66e3d3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/controllers/team_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ func UpdateTeamName(ctx echo.Context) error {

err := services.UpdateTeamName(payload.Name, user.TeamID)
if err != nil {
var pgerr *pgconn.PgError
if errors.As(err, &pgerr) {
if pgerr.Code == "23505" {
return ctx.JSON(http.StatusConflict, map[string]string{
"message": "team name already exists",
"status": "failed to update team",
})
}
}
return ctx.JSON(http.StatusInternalServerError, map[string]string{
"message": err.Error(),
"status": "error",
Expand Down

0 comments on commit c66e3d3

Please sign in to comment.