From bfe6f6c2dc70a719a38b653211ae089002f8ac37 Mon Sep 17 00:00:00 2001 From: "huangsimin@fusen.cn" Date: Mon, 4 Mar 2024 17:43:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0panic=E7=9A=84=E5=80=BC?= =?UTF-8?q?=E6=89=93=E5=8D=B0=E5=87=BA=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- goutils/proto_build/tpls/logic_grpc_struct.tpl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/goutils/proto_build/tpls/logic_grpc_struct.tpl b/goutils/proto_build/tpls/logic_grpc_struct.tpl index 408c23f..41591ae 100644 --- a/goutils/proto_build/tpls/logic_grpc_struct.tpl +++ b/goutils/proto_build/tpls/logic_grpc_struct.tpl @@ -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)