From ccf1a237b699cb8062113de9e15136ac6c52e1a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ron=20Nosz=C3=A1ly?= Date: Tue, 3 Sep 2024 21:12:15 +0200 Subject: [PATCH] fix #120 again --- internal/web/handlers/problemset/middleware.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/web/handlers/problemset/middleware.go b/internal/web/handlers/problemset/middleware.go index d15cb94..7032675 100644 --- a/internal/web/handlers/problemset/middleware.go +++ b/internal/web/handlers/problemset/middleware.go @@ -3,12 +3,13 @@ package problemset import ( "errors" "fmt" - "github.com/mraron/njudge/internal/web/handlers/user" - "github.com/mraron/njudge/internal/web/templates" "net/http" "slices" "strings" + "github.com/mraron/njudge/internal/web/handlers/user" + "github.com/mraron/njudge/internal/web/templates" + "github.com/labstack/echo/v4" "github.com/mraron/njudge/internal/njudge" "github.com/mraron/njudge/pkg/problems" @@ -25,6 +26,9 @@ func SetMiddleware(ps njudge.Problemsets) func(echo.HandlerFunc) echo.HandlerFun return func(next echo.HandlerFunc) echo.HandlerFunc { return func(c echo.Context) error { if r, err := ps.GetByName(c.Request().Context(), c.Param("name")); err != nil { + if errors.Is(err,njudge.ErrorProblemsetNotFound) { + return echo.NewHTTPError(http.StatusNotFound, err.Error() ) + } return err } else { c.Set(ContextKey, r)