MemberAlreadyExists returns UnprocessableEntity.

This commit is contained in:
Miroslav Šedivý 2021-09-09 00:33:11 +02:00
parent e0f1857c51
commit 9deb5adee1

View File

@ -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 {
if errors.Is(err, types.ErrMemberAlreadyExists) {
utils.HttpUnprocessableEntity(w, err)
} else {
utils.HttpInternalServerError(w, err)
}
return
}