diff --git a/goutils/proto_build/tpls/logic_grpc_struct.tpl b/goutils/proto_build/tpls/logic_grpc_struct.tpl index 408c23f..251c803 100644 --- a/goutils/proto_build/tpls/logic_grpc_struct.tpl +++ b/goutils/proto_build/tpls/logic_grpc_struct.tpl @@ -5,8 +5,10 @@ import ( "context" "sync" "fmt" + "runtime/debug" "fusen-basic/env" + "fusen-basic/utils/log" "{{.ProjectName}}/gen/go/service" "{{.ProjectName}}/server/config" @@ -53,6 +55,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 +67,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)