Skip to content

Commit

Permalink
add return err when user is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
Hueter57 committed Nov 8, 2024
1 parent 0f76080 commit a0ff91a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions router/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/labstack/echo-contrib/session"
"github.com/labstack/echo/v4"
"github.com/samber/lo"
"github.com/traPtitech/Jomon/ent"
"github.com/traPtitech/Jomon/model"
"go.uber.org/zap"
)
Expand Down Expand Up @@ -93,6 +94,10 @@ func (h Handlers) GetMe(c echo.Context) error {

user, err := h.Repository.GetUserByID(c.Request().Context(), userInSession.ID)
if err != nil {
if ent.IsNotFound(err) {
h.Logger.Error("failed to find user from DB by ID")
return c.JSON(http.StatusNotFound, err)
}
h.Logger.Error("failed to get user by ID")
return c.JSON(http.StatusInternalServerError, err)
}
Expand Down

0 comments on commit a0ff91a

Please sign in to comment.