From 7056d6604b66d51f50ba32c46a54abd67378bc08 Mon Sep 17 00:00:00 2001 From: Wenkai Yin Date: Mon, 23 Sep 2019 13:03:18 +0800 Subject: [PATCH] Return the common error message when testing the webhook endpoint This commit returns a common error message when testing the webhook endpoint and prints the detail in the log for debug Signed-off-by: Wenkai Yin --- src/core/api/notification_policy.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/api/notification_policy.go b/src/core/api/notification_policy.go index 597e3e4f1..324227d15 100755 --- a/src/core/api/notification_policy.go +++ b/src/core/api/notification_policy.go @@ -7,6 +7,8 @@ import ( "strconv" "time" + "github.com/goharbor/harbor/src/common/utils/log" + "github.com/goharbor/harbor/src/common/models" "github.com/goharbor/harbor/src/common/rbac" "github.com/goharbor/harbor/src/common/utils" @@ -273,7 +275,8 @@ func (w *NotificationPolicyAPI) Test() { } if err := notification.PolicyMgr.Test(policy); err != nil { - w.SendBadRequestError(fmt.Errorf("notification policy %s test failed: %v", policy.Name, err)) + log.Errorf("notification policy %s test failed: %v", policy.Name, err) + w.SendBadRequestError(fmt.Errorf("notification policy %s test failed", policy.Name)) return } }