chore: improve error message on adding existing org_member (#13621)

This commit is contained in:
Steven Masley
2024-06-20 18:05:11 -05:00
committed by GitHub
parent 889daf200e
commit 2ef2f97388
3 changed files with 33 additions and 0 deletions
+6
View File
@@ -43,6 +43,12 @@ func (api *API) postOrganizationMember(rw http.ResponseWriter, r *http.Request)
httpapi.ResourceNotFound(rw)
return
}
if database.IsUniqueViolation(err, database.UniqueOrganizationMembersPkey) {
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
Message: "Organization member already exists in this organization",
})
return
}
if err != nil {
httpapi.InternalServerError(rw, err)
return