From a0ff91a25468fea3f99b9fccb084fd22945d4ec1 Mon Sep 17 00:00:00 2001 From: Hueter Date: Sat, 9 Nov 2024 01:23:18 +0900 Subject: [PATCH] add return err when user is not found --- router/user.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/router/user.go b/router/user.go index 8dcc524f..635da01b 100644 --- a/router/user.go +++ b/router/user.go @@ -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" ) @@ -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) }