From 87e9f5ed48af3a8dca5f6373ae900336f285eef5 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 15 Feb 2026 17:54:01 +0900 Subject: fix(backend): replace panic() with proper error handling in runtime code auth/auth.go: return error instead of panicking on data inconsistency. game/hub.go: log unexpected task result types instead of panicking. Co-Authored-By: Claude Opus 4.6 --- backend/auth/auth.go | 2 +- backend/game/hub.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/auth/auth.go b/backend/auth/auth.go index b79161f..7d9a4c2 100644 --- a/backend/auth/auth.go +++ b/backend/auth/auth.go @@ -39,7 +39,7 @@ func Login( // Authenticate with password. passwordHash := userAuth.PasswordHash if passwordHash == nil { - panic("inconsistant data") + return 0, errors.New("inconsistent data: password auth type but no password hash") } err := bcrypt.CompareHashAndPassword([]byte(*passwordHash), []byte(password)) if err != nil { diff --git a/backend/game/hub.go b/backend/game/hub.go index c9e9680..d918543 100644 --- a/backend/game/hub.go +++ b/backend/game/hub.go @@ -97,7 +97,8 @@ func (hub *Hub) processTaskResults() { continue } default: - panic("unexpected task result type") + slog.Error("unexpected task result type", "type", taskResult.Type()) + continue } } } -- cgit v1.3.1