Skip to content

Commit

Permalink
feat: bad request on invalid json
Browse files Browse the repository at this point in the history
  • Loading branch information
jackmcguire1 committed Sep 28, 2023
1 parent 0b4ad81 commit 23b6ff7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions api/userapi/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (h *UserHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
WithField("body", string(reqData)).
Error("failed to get user data from request body")

w.WriteHeader(http.StatusInternalServerError)
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte(err.Error()))

return
Expand Down Expand Up @@ -168,7 +168,7 @@ func (h *UserHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
WithError(err).
Error("failed to unmarshal user data from request body")

w.WriteHeader(http.StatusInternalServerError)
w.WriteHeader(http.StatusBadRequest)
w.Write(utils.ToRAWJSON(api.HTTPError{Error: err.Error()}))

return
Expand Down

0 comments on commit 23b6ff7

Please sign in to comment.