This commit is contained in:
@@ -105,8 +105,15 @@ func (s *Server) OnTraffic(c gnet.Conn) (action gnet.Action) {
|
||||
defer func() {
|
||||
if err := recover(); err != nil { // 恢复 panic,err 为 panic 错误值
|
||||
// 1. 打印错误信息
|
||||
if t, ok := c.Context().(*player.ClientData); ok {
|
||||
if t.Player != nil {
|
||||
if t.Player.Info != nil {
|
||||
cool.Logger.Error(context.TODO(), "panic 错误:", t.Player.Info.UserID, err)
|
||||
}
|
||||
|
||||
cool.Logger.Error(context.TODO(), "panic 错误:", err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user