diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-07-31 21:47:05 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-07-31 21:47:15 +0900 |
| commit | 715651d6d263c5f526e8e13a8e2bb032193c5218 (patch) | |
| tree | 9ed66437bc86c0b1d5f75831a084347b9febed1b /backend/api/handlers.go | |
| parent | 9e634d64153b2d6dff86cafd1765db02a1224af4 (diff) | |
| download | iosdc-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.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 { |
