更新panic的值打印出日志

This commit is contained in:
huangsimin@fusen.cn 2024-03-04 17:43:48 +08:00
parent b4ca304f8d
commit bfe6f6c2dc

View File

@ -7,6 +7,7 @@ import (
"fmt"
"fusen-basic/env"
"fusen-basic/utils/log"
"{{.ProjectName}}/gen/go/service"
"{{.ProjectName}}/server/config"
@ -53,6 +54,7 @@ func (lgrpc *{{.StructName}}Grpc) {{.MethodName}}({{range $index, $param := .Par
if _recoverErr := recover(); _recoverErr != nil {
_resp = nil
_err = fmt.Errorf("%v", _recoverErr)
log.Printf("recovered from panic: %v\n%s", _err, string(debug.Stack()))
}
}()
return New{{.StructName}}(ctx).{{.MethodName}}Logic({{range $index, $param := .ParamsName}}{{if $index}}, {{end}}{{$param}}{{end}})
@ -64,6 +66,7 @@ func (lgrpc *{{.StructName}}Grpc) {{.MethodName}}(stream {{range $index, $param
defer func() {
if _recoverErr := recover(); _recoverErr != nil {
_err = fmt.Errorf("%v", _recoverErr)
log.Printf("recovered from panic: %v\n%s", _err, string(debug.Stack()))
}
}()
return New{{.StructName}}(stream.Context()).{{.MethodName}}Logic(stream)