Skip to content

Commit

Permalink
fix #120 again
Browse files Browse the repository at this point in the history
  • Loading branch information
mraron committed Sep 3, 2024
1 parent 89083f2 commit ccf1a23
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions internal/web/handlers/problemset/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand Down

0 comments on commit ccf1a23

Please sign in to comment.