From bfe6f6c2dc70a719a38b653211ae089002f8ac37 Mon Sep 17 00:00:00 2001 From: "huangsimin@fusen.cn" Date: Mon, 4 Mar 2024 17:43:48 +0800 Subject: [PATCH 1/2] =?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) From 2f19ba354ed599ef94aeb96ea8eba38b1820036d Mon Sep 17 00:00:00 2001 From: "huangsimin@fusen.cn" Date: Mon, 4 Mar 2024 17:44:50 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20debug=20=E4=BE=9D?= =?UTF-8?q?=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- goutils/proto_build/tpls/logic_grpc_struct.tpl | 1 + 1 file changed, 1 insertion(+) diff --git a/goutils/proto_build/tpls/logic_grpc_struct.tpl b/goutils/proto_build/tpls/logic_grpc_struct.tpl index 41591ae..251c803 100644 --- a/goutils/proto_build/tpls/logic_grpc_struct.tpl +++ b/goutils/proto_build/tpls/logic_grpc_struct.tpl @@ -5,6 +5,7 @@ import ( "context" "sync" "fmt" + "runtime/debug" "fusen-basic/env" "fusen-basic/utils/log"