diff options
Diffstat (limited to 'backend/api/handlers.go')
| -rw-r--r-- | backend/api/handlers.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/backend/api/handlers.go b/backend/api/handlers.go index b38fd9b..519695f 100644 --- a/backend/api/handlers.go +++ b/backend/api/handlers.go @@ -2,9 +2,11 @@ package api import ( "context" + "errors" "net/http" "strings" + "github.com/jackc/pgx/v5" "github.com/labstack/echo/v4" "github.com/nsfisis/iosdc-2024-albatross/backend/auth" @@ -176,7 +178,13 @@ func (h *ApiHandler) GetGamesGameId(ctx context.Context, request GetGamesGameIdR gameId := request.GameId row, err := h.q.GetGameById(ctx, int32(gameId)) if err != nil { - return nil, echo.NewHTTPError(http.StatusInternalServerError, err.Error()) + if errors.Is(err, pgx.ErrNoRows) { + return GetGamesGameId404JSONResponse{ + Message: "Game not found", + }, nil + } else { + return nil, echo.NewHTTPError(http.StatusInternalServerError, err.Error()) + } } var startedAt *int if row.StartedAt.Valid { |
