From c7068102de960e0621083ab00cd512b2e31ddd61 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 19 Jan 2022 08:48:23 +0800 Subject: [PATCH] =?UTF-8?q?hook=20=E9=9D=99=E9=BB=98=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=EF=BC=8C=E5=A4=B1=E8=B4=A5=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- table/table.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/table/table.go b/table/table.go index bf2a5c08..1b7883aa 100644 --- a/table/table.go +++ b/table/table.go @@ -161,13 +161,18 @@ func (table *Table) Before(process string, processArgs []interface{}) []interfac res = append(res, processArgs[0]) } - response := gou.NewProcess(process, args...).Run() + response, err := gou.NewProcess(process, args...).Exec() + if err != nil { + xlog.Println("Hook执行失败: ", err.Error(), maps.StrAny{"process": process, "args": args}) + return processArgs + } + if fixedArgs, ok := response.([]interface{}); ok { res = append(res, fixedArgs...) return res } - xlog.Println("无效的处理器", maps.StrAny{"process": process, "response": response}) + xlog.Println("Hook执行失败: 无效的处理器", maps.StrAny{"process": process, "response": response}) return processArgs } @@ -176,7 +181,12 @@ func (table *Table) After(process string, data interface{}) interface{} { if process == "" { return data } - return gou.NewProcess(process, data).Run() + response, err := gou.NewProcess(process, data).Exec() + if err != nil { + xlog.Println("Hook执行失败: ", err.Error(), maps.StrAny{"process": process, "data": data}) + return data + } + return response } // loadFilters 加载查询过滤器