Skip to content

Commit

Permalink
update: ユーザー登録時に400 bad request エラーが発生したので、ログ出力による原因を追求
Browse files Browse the repository at this point in the history
  • Loading branch information
YKhm20020 committed Nov 15, 2024
1 parent b6ef246 commit 750a002
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/api/controller/create_user.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package controller

import (
"fmt"
"net/http"

"github.com/YKhm20020/Backend-Tacktail/usecase"
Expand All @@ -21,6 +22,7 @@ func (con CreateUser) Execute(ctx *gin.Context) {
var input usecase.CreateUserInput

if err := ctx.ShouldBindJSON(&input); err != nil {
fmt.Println("should bind json でエラー発生: ", err)
ctx.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
Expand All @@ -29,6 +31,7 @@ func (con CreateUser) Execute(ctx *gin.Context) {

if err != nil {
if err.Error() == "this name is already registered" {
fmt.Println("this name is already registeredでエラー発生: ", err)
ctx.JSON(http.StatusBadRequest, gin.H{"error": "This name is already registered"})
return
}
Expand Down

0 comments on commit 750a002

Please sign in to comment.