From 1f1dce7e23d4a8c9c82d8a3a3672359e5a6bb1d2 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Wed, 10 Jan 2024 10:05:05 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E5=BC=82=E6=AD=A5=E5=A4=84?= =?UTF-8?q?=E7=90=86=E5=BC=82=E5=B8=B8=E6=8D=95=E6=8D=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/modulebase.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/modulebase.go b/modules/modulebase.go index 38a65dbf9..bf873b522 100644 --- a/modules/modulebase.go +++ b/modules/modulebase.go @@ -7,6 +7,7 @@ import ( "go_dreamfactory/lego/base" "go_dreamfactory/lego/core" "go_dreamfactory/lego/core/cbase" + "runtime" "time" "go_dreamfactory/lego/sys/log" @@ -983,6 +984,14 @@ func (this *ModuleBase) FormatRes(res []*cfg.Gameatn) (ret []*cfg.Gameatn) { //异步调用用户处理流 func (this *ModuleBase) AsynHandleSession(session comm.IUserSession, handle func(session comm.IUserSession)) { + defer func() { //程序异常 收集异常信息传递给前端显示 + if r := recover(); r != nil { + buf := make([]byte, 4096) + l := runtime.Stack(buf, false) + err := fmt.Errorf("%v: %s", r, buf[:l]) + log.Errorf("[AsynHandleSession] err:%s", err.Error()) + } + }() handle(session) session.Push() this.PutUserSession(session)