fix: replace panic calls with proper error handling

Remove 51 panic() calls from handler code and replace with:
- Proper error logging using zap
- Appropriate client error responses (doAckBufFail, doAckSimpleFail)
- Graceful error recovery instead of server crashes

Files updated:
- handlers_guild_scout.go (9 panics)
- handlers_guild_tresure.go (10 panics)
- handlers_guild.go (7 panics + dead code removal)
- handlers_mail.go (5 panics)
- handlers.go (9 panics)
- handlers_tower.go (2 panics)
- handlers_clients.go (3 panics)
- handlers_guild_alliance.go (1 panic)
- handlers_quest.go (1 panic)
- handlers_rengoku.go (1 panic)
- handlers_stage.go (1 panic)
- handlers_data.go (1 panic)
- handlers_cafe.go (1 panic)
- signserver/sign_server.go (1 panic)

Remaining panics (3) are in test files and compression library
where panicking on programming errors is appropriate.
This commit is contained in:
Houmgaor
2026-02-02 17:14:34 +01:00
parent dbc3b21827
commit f138cb5f77
15 changed files with 203 additions and 108 deletions

View File

@@ -3,6 +3,7 @@ package channelserver
import (
"encoding/hex"
"erupe-ce/network/mhfpacket"
"go.uber.org/zap"
)
func handleMsgMhfGetTowerInfo(s *Session, p mhfpacket.MHFPacket) {
@@ -40,7 +41,9 @@ func handleMsgMhfGetTowerInfo(s *Session, p mhfpacket.MHFPacket) {
//data, err = hex.DecodeString("0A218EAD000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
data, err = hex.DecodeString("0A218EAD0000000000000000000000010000001C0000000500050000000000020000000000000000000000000000000000030003000000000003000500050000000300030003000300030003000200030001000300020002000300010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
case mhfpacket.TowerInfoTypeGetOwnTowerLevelV3:
panic("No known response values for GetOwnTowerLevelV3")
// TODO: No known response values for GetOwnTowerLevelV3
stubGetNoResults(s, pkt.AckHandle)
return
case mhfpacket.TowerInfoTypeTowerTouhaHistory:
data, err = hex.DecodeString("0A218EAD0000000000000000000000010000000000000000000000000000000000000000")
case mhfpacket.TowerInfoTypeUnk5:
@@ -72,7 +75,9 @@ func handleMsgMhfGetTenrouirai(s *Session, p mhfpacket.MHFPacket) {
s.logger.Info("GET_TENROUIRAI request for unknown type")
}
if err != nil {
panic(err)
s.logger.Error("failed to decode tenrouirai hex data", zap.Error(err))
doAckBufSucceed(s, pkt.AckHandle, []byte{0x00, 0x00, 0x00, 0x00})
return
}
doAckBufSucceed(s, pkt.AckHandle, data)
}