mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-27 01:53:19 +01:00
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:
@@ -147,8 +147,8 @@ func handleMsgMhfLoadHouse(s *Session, p mhfpacket.MHFPacket) {
|
||||
// Guild verification
|
||||
if state > 3 {
|
||||
ownGuild, err := s.server.guildRepo.GetByCharID(s.charID)
|
||||
isApplicant, _ := s.server.guildRepo.HasApplication(ownGuild.ID, s.charID)
|
||||
if err == nil && ownGuild != nil {
|
||||
isApplicant, _ := s.server.guildRepo.HasApplication(ownGuild.ID, s.charID)
|
||||
othersGuild, err := s.server.guildRepo.GetByCharID(pkt.CharID)
|
||||
if err == nil && othersGuild != nil {
|
||||
if othersGuild.ID == ownGuild.ID && !isApplicant {
|
||||
@@ -164,7 +164,12 @@ func handleMsgMhfLoadHouse(s *Session, p mhfpacket.MHFPacket) {
|
||||
}
|
||||
}
|
||||
|
||||
houseTier, houseData, houseFurniture, bookshelf, gallery, tore, garden, _ := s.server.houseRepo.GetHouseContents(pkt.CharID)
|
||||
houseTier, houseData, houseFurniture, bookshelf, gallery, tore, garden, err := s.server.houseRepo.GetHouseContents(pkt.CharID)
|
||||
if err != nil {
|
||||
s.logger.Error("Failed to get house contents", zap.Error(err), zap.Uint32("charID", pkt.CharID))
|
||||
doAckSimpleFail(s, pkt.AckHandle, make([]byte, 4))
|
||||
return
|
||||
}
|
||||
if houseFurniture == nil {
|
||||
houseFurniture = make([]byte, 20)
|
||||
}
|
||||
@@ -201,7 +206,10 @@ func handleMsgMhfLoadHouse(s *Session, p mhfpacket.MHFPacket) {
|
||||
|
||||
func handleMsgMhfGetMyhouseInfo(s *Session, p mhfpacket.MHFPacket) {
|
||||
pkt := p.(*mhfpacket.MsgMhfGetMyhouseInfo)
|
||||
data, _ := s.server.houseRepo.GetMission(s.charID)
|
||||
data, err := s.server.houseRepo.GetMission(s.charID)
|
||||
if err != nil {
|
||||
s.logger.Error("Failed to get myhouse mission", zap.Error(err))
|
||||
}
|
||||
if len(data) > 0 {
|
||||
doAckBufSucceed(s, pkt.AckHandle, data)
|
||||
} else {
|
||||
@@ -343,7 +351,10 @@ func handleMsgMhfOperateWarehouse(s *Session, p mhfpacket.MHFPacket) {
|
||||
switch pkt.Operation {
|
||||
case 0:
|
||||
var count uint8
|
||||
itemNames, equipNames, _ := s.server.houseRepo.GetWarehouseNames(s.charID)
|
||||
itemNames, equipNames, err := s.server.houseRepo.GetWarehouseNames(s.charID)
|
||||
if err != nil {
|
||||
s.logger.Error("Failed to get warehouse names", zap.Error(err))
|
||||
}
|
||||
bf.WriteUint32(0)
|
||||
bf.WriteUint16(10000) // Usages
|
||||
temp := byteframe.NewByteFrame()
|
||||
|
||||
Reference in New Issue
Block a user