From 1bbc453871cf4f6ac13c3f39503c75b53e19db34 Mon Sep 17 00:00:00 2001 From: zijiren233 Date: Tue, 17 Oct 2023 20:04:57 +0800 Subject: [PATCH] Fix: handle err --- server/handlers/movie.go | 4 ++++ server/handlers/room.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/server/handlers/movie.go b/server/handlers/movie.go index b020dea..dd52ad1 100644 --- a/server/handlers/movie.go +++ b/server/handlers/movie.go @@ -344,6 +344,10 @@ func ProxyMovie(ctx *gin.Context) { return } id, err := strconv.ParseUint(roomId, 10, 64) + if err != nil { + ctx.AbortWithStatusJSON(http.StatusBadRequest, model.NewApiErrorResp(err)) + return + } room, err := op.GetRoomByID(uint(id)) if err != nil { ctx.AbortWithStatusJSON(http.StatusBadRequest, model.NewApiErrorResp(err)) diff --git a/server/handlers/room.go b/server/handlers/room.go index 8fefda8..c5e0bc9 100644 --- a/server/handlers/room.go +++ b/server/handlers/room.go @@ -180,6 +180,10 @@ func RoomList(ctx *gin.Context) { func CheckRoom(ctx *gin.Context) { id, err := strconv.Atoi(ctx.Query("roomId")) + if err != nil { + ctx.AbortWithStatusJSON(http.StatusBadRequest, model.NewApiErrorResp(err)) + return + } r, err := op.GetRoomByID(uint(id)) if err != nil {