aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend/api/handlers.go
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-07-31 21:47:05 +0900
committernsfisis <nsfisis@gmail.com>2024-07-31 21:47:15 +0900
commit715651d6d263c5f526e8e13a8e2bb032193c5218 (patch)
tree9ed66437bc86c0b1d5f75831a084347b9febed1b /backend/api/handlers.go
parent9e634d64153b2d6dff86cafd1765db02a1224af4 (diff)
downloadiosdc-japan-2024-albatross-715651d6d263c5f526e8e13a8e2bb032193c5218.tar.gz
iosdc-japan-2024-albatross-715651d6d263c5f526e8e13a8e2bb032193c5218.tar.zst
iosdc-japan-2024-albatross-715651d6d263c5f526e8e13a8e2bb032193c5218.zip
fix: adjust /games/{gameId} definition
Diffstat (limited to 'backend/api/handlers.go')
-rw-r--r--backend/api/handlers.go10
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 {