Unify error handling and HTTP statuses

Signed-off-by: Sean Du <do4suki@gmail.com>
This commit is contained in:
2026-07-11 16:18:17 +08:00
parent 61b33ae0e3
commit cb8f587e30
113 changed files with 408 additions and 166 deletions
+2 -1
View File
@@ -5,6 +5,7 @@ import (
"honoka-chan/internal/router"
liveschema "honoka-chan/internal/schema/live"
"honoka-chan/internal/session"
"net/http"
"time"
"github.com/gin-gonic/gin"
@@ -25,7 +26,7 @@ func BuildContinueResp(ss *session.Session) liveschema.ContinueResp {
ServerTimestamp: time.Now().Unix(),
},
ReleaseInfo: []any{},
StatusCode: 200,
StatusCode: http.StatusOK,
}
}
+2 -1
View File
@@ -5,6 +5,7 @@ import (
"honoka-chan/internal/router"
liveschema "honoka-chan/internal/schema/live"
"honoka-chan/internal/session"
"net/http"
"github.com/gin-gonic/gin"
)
@@ -25,7 +26,7 @@ func BuildGameOverResp() liveschema.GameOverResp {
return liveschema.GameOverResp{
ResponseData: []any{},
ReleaseInfo: []any{},
StatusCode: 200,
StatusCode: http.StatusOK,
}
}
+2 -1
View File
@@ -6,6 +6,7 @@ import (
"honoka-chan/internal/router"
liveschema "honoka-chan/internal/schema/live"
"honoka-chan/internal/session"
"net/http"
"time"
"github.com/gin-gonic/gin"
@@ -22,7 +23,7 @@ func partyList(ctx *gin.Context) {
ss.Respond(liveschema.PartyListResp{
ResponseData: partyListData,
ReleaseInfo: []any{},
StatusCode: 200,
StatusCode: http.StatusOK,
})
}
+2 -1
View File
@@ -8,6 +8,7 @@ import (
"honoka-chan/internal/session"
honokautils "honoka-chan/internal/utils"
"math"
"net/http"
"strconv"
"time"
@@ -322,7 +323,7 @@ func BuildPlayResp(ss *session.Session, playReq liveschema.PlayReq, isRandom boo
ServerTimestamp: time.Now().Unix(),
},
ReleaseInfo: []any{},
StatusCode: 200,
StatusCode: http.StatusOK,
}, nil
}
+4 -3
View File
@@ -10,6 +10,7 @@ import (
liverecordschema "honoka-chan/internal/schema/liverecord"
"honoka-chan/internal/session"
honokautils "honoka-chan/internal/utils"
"net/http"
"time"
"github.com/gin-gonic/gin"
@@ -88,7 +89,7 @@ func preciseScore(ctx *gin.Context) {
ServerTimestamp: time.Now().Unix(),
},
ReleaseInfo: []any{},
StatusCode: 200,
StatusCode: http.StatusOK,
}
} else {
// 如果有 Live 记录
@@ -181,7 +182,7 @@ func preciseScore(ctx *gin.Context) {
ServerTimestamp: time.Now().Unix(),
},
ReleaseInfo: []any{},
StatusCode: 200,
StatusCode: http.StatusOK,
}
} else {
playResp = liveschema.PreciseScoreResp{
@@ -189,7 +190,7 @@ func preciseScore(ctx *gin.Context) {
ErrorCode: constant.ErrorCodeLivePreciseListNotFound,
},
ReleaseInfo: []any{},
StatusCode: 600,
StatusCode: constant.ErrorCodeAcceptableError,
}
}
}
+2 -1
View File
@@ -9,6 +9,7 @@ import (
"honoka-chan/internal/session"
honokautils "honoka-chan/internal/utils"
"honoka-chan/pkg/utils"
"net/http"
"time"
"github.com/gin-gonic/gin"
@@ -172,7 +173,7 @@ func BuildRewardResp(ss *session.Session, playRewardReq liveschema.RewardReq, is
PresentCnt: 0,
},
ReleaseInfo: []any{},
StatusCode: 200,
StatusCode: http.StatusOK,
}
if playRewardReq.MaxCombo >= liveInfo.SRankCombo {