diff --git a/internal/web/handlers/user/profile/middleware.go b/internal/web/handlers/user/profile/middleware.go index 03ddb7e..9e8566f 100644 --- a/internal/web/handlers/user/profile/middleware.go +++ b/internal/web/handlers/user/profile/middleware.go @@ -1,10 +1,12 @@ package profile import ( - "github.com/mraron/njudge/internal/web/templates" + "errors" "net/http" "net/url" + "github.com/mraron/njudge/internal/web/templates" + "github.com/labstack/echo/v4" "github.com/mraron/njudge/internal/njudge" ) @@ -27,6 +29,9 @@ func SetProfileMiddleware(u njudge.Users) echo.MiddlewareFunc { user, err := u.GetByName(c.Request().Context(), name) if err != nil { + if errors.Is(err,njudge.ErrorUserNotFound) { + return echo.NewHTTPError(http.StatusNotFound, err.Error() ) + } return err }