fix(handlers): add error handling for swallowed repo/service errors

Several handler files discarded errors from repository and service
calls, creating nil-dereference risks and silent data corruption:

- guild_adventure: 3 GetByCharID calls could panic on nil guild
- gacha: GetGachaPoints silently returned zero balances on DB error
- house: HasApplication called before nil check on guild;
  GetHouseContents error discarded with 7 return values
- distitem: 3 distRepo calls had no error logging
- guild_ops: Disband/Leave service errors were invisible
- shop: gacha type/weight/fpoint lookups had no error logging
- discord: bcrypt error could result in nil password being set
This commit is contained in:
Houmgaor
2026-02-24 13:55:49 +01:00
parent 2f92b4ff62
commit 8fead0b1f3
8 changed files with 221 additions and 19 deletions

View File

@@ -27,7 +27,10 @@ func handleMsgMhfOperateGuild(s *Session, p mhfpacket.MHFPacket) {
switch pkt.Action {
case mhfpacket.OperateGuildDisband:
result, _ := s.server.guildService.Disband(s.charID, guild.ID)
result, err := s.server.guildService.Disband(s.charID, guild.ID)
if err != nil {
s.logger.Error("Failed to disband guild", zap.Error(err))
}
response := 0
if result != nil && result.Success {
response = 1
@@ -46,7 +49,10 @@ func handleMsgMhfOperateGuild(s *Session, p mhfpacket.MHFPacket) {
bf.WriteUint32(0)
}
case mhfpacket.OperateGuildLeave:
result, _ := s.server.guildService.Leave(s.charID, guild.ID, characterGuildInfo.IsApplicant, guild.Name)
result, err := s.server.guildService.Leave(s.charID, guild.ID, characterGuildInfo.IsApplicant, guild.Name)
if err != nil {
s.logger.Error("Failed to leave guild", zap.Error(err))
}
response := 0
if result != nil && result.Success {
response = 1