From 0941c171ef53299fb8042621deb2ebefbad01ec6 Mon Sep 17 00:00:00 2001 From: yedf2 <120050102@qq.com> Date: Sat, 18 Dec 2021 08:54:17 +0800 Subject: [PATCH] RecoverPanic fixed --- common/utils.go | 2 +- common/utils_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/utils.go b/common/utils.go index 26bcf6c..24e25d7 100644 --- a/common/utils.go +++ b/common/utils.go @@ -90,7 +90,7 @@ func RecoverPanic(err *error) { if x := recover(); x != nil { e := dtmimp.AsError(x) if err != nil { - err = &e + *err = e } } } diff --git a/common/utils_test.go b/common/utils_test.go index 1a9f722..a3240a2 100644 --- a/common/utils_test.go +++ b/common/utils_test.go @@ -49,7 +49,7 @@ func TestFuncs(t *testing.T) { func TestRecoverPanic(t *testing.T) { err := func() (rerr error) { - RecoverPanic(&rerr) + defer RecoverPanic(&rerr) panic(fmt.Errorf("an error")) }() assert.Equal(t, "an error", err.Error())