diff --git a/internal/api/members/controler.go b/internal/api/members/controler.go index a6a44a94..09f626d2 100644 --- a/internal/api/members/controler.go +++ b/internal/api/members/controler.go @@ -1,6 +1,7 @@ package members import ( + "errors" "net/http" "strconv" @@ -82,7 +83,11 @@ func (h *MembersHandler) membersCreate(w http.ResponseWriter, r *http.Request) { id, err := h.members.Insert(data.Username, data.Password, data.Profile) if err != nil { - utils.HttpInternalServerError(w, err) + if errors.Is(err, types.ErrMemberAlreadyExists) { + utils.HttpUnprocessableEntity(w, err) + } else { + utils.HttpInternalServerError(w, err) + } return }