aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-02-15 17:54:01 +0900
committernsfisis <nsfisis@gmail.com>2026-02-15 17:54:01 +0900
commit87e9f5ed48af3a8dca5f6373ae900336f285eef5 (patch)
tree6b8ada3c17d874cbd2627a61c00df83d38da2c8a
parent557b238e88189e1314c39af82d77c94ba9dbd19e (diff)
downloadphperkaigi-2026-albatross-87e9f5ed48af3a8dca5f6373ae900336f285eef5.tar.gz
phperkaigi-2026-albatross-87e9f5ed48af3a8dca5f6373ae900336f285eef5.tar.zst
phperkaigi-2026-albatross-87e9f5ed48af3a8dca5f6373ae900336f285eef5.zip
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 <noreply@anthropic.com>
-rw-r--r--backend/auth/auth.go2
-rw-r--r--backend/game/hub.go3
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
}
}
}