补充异步处理异常捕捉
This commit is contained in:
parent
1d1150a0fa
commit
1f1dce7e23
@ -7,6 +7,7 @@ import (
|
|||||||
"go_dreamfactory/lego/base"
|
"go_dreamfactory/lego/base"
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
"go_dreamfactory/lego/core/cbase"
|
"go_dreamfactory/lego/core/cbase"
|
||||||
|
"runtime"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go_dreamfactory/lego/sys/log"
|
"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)) {
|
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)
|
handle(session)
|
||||||
session.Push()
|
session.Push()
|
||||||
this.PutUserSession(session)
|
this.PutUserSession(session)
|
||||||
|
Loading…
Reference in New Issue
Block a user