notify: Return detailed err msg when connecting to target fails (#16118)

This commit is contained in:
Anis Elleuch 2022-11-24 16:59:19 +01:00 committed by GitHub
parent 59f877fc64
commit 97eb7dbf5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,6 +22,7 @@ import (
"crypto/tls"
"crypto/x509"
"errors"
"fmt"
"net/http"
"strconv"
"strings"
@ -59,8 +60,11 @@ func TestSubSysNotificationTargets(ctx context.Context, cfg config.Config, subSy
for _, target := range targetList {
yes, err := target.IsActive()
if err != nil || !yes {
return ErrTargetsOffline
if err == nil && !yes {
err = ErrTargetsOffline
}
if err != nil {
return fmt.Errorf("error (%s): %w", target.ID(), err)
}
}