Skip to content

Commit

Permalink
chore: debug bad request (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
ImSoZRious authored Jan 9, 2024
1 parent ad61ae2 commit 3d3d1bc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/auth/auth.handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func (h *handlerImpl) Register(c *gin.Context) {
var data dto.RegisterRequestDTO

if err := c.ShouldBindJSON(&data); err != nil {
h.logger.Debug("Bad request", zap.Error(err))
utils.ReturnError(c, apperror.BadRequest)
return
}
Expand Down
1 change: 1 addition & 0 deletions internal/auth/auth.service.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func (s *serviceImpl) Register(email string, data *dto.RegisterRequestDTO) (*dto
if errors.Is(err, gorm.ErrDuplicatedKey) {
return nil, apperror.DuplicateEmail
} else if errors.Is(err, gorm.ErrForeignKeyViolated) {
s.logger.Debug("Invalid foreign key", zap.Error(err))
return nil, apperror.BadRequest
} else if err != nil {
s.logger.Error("Failed to create user", zap.Error(err), zap.Any("register", data))
Expand Down

0 comments on commit 3d3d1bc

Please sign in to comment.