Skip to content

Commit

Permalink
Merge pull request #375 from fluxcd/error-msg-providers
Browse files Browse the repository at this point in the history
Better error messages for alert providers
  • Loading branch information
stefanprodan authored May 22, 2022
2 parents 01b428d + 39b2717 commit a395873
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion internal/notifier/alertmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type AlertManagerAlert struct {
func NewAlertmanager(hookURL string, proxyURL string, certPool *x509.CertPool) (*Alertmanager, error) {
_, err := url.ParseRequestURI(hookURL)
if err != nil {
return nil, fmt.Errorf("invalid Alertmanager URL %s", hookURL)
return nil, fmt.Errorf("invalid Alertmanager URL %s: '%w'", hookURL, err)
}

return &Alertmanager{
Expand Down
2 changes: 1 addition & 1 deletion internal/notifier/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type Discord struct {
func NewDiscord(hookURL string, proxyURL string, username string, channel string) (*Discord, error) {
webhook, err := url.ParseRequestURI(hookURL)
if err != nil {
return nil, fmt.Errorf("invalid Discord hook URL %s", hookURL)
return nil, fmt.Errorf("invalid Discord hook URL %s: '%w'", hookURL, err)
}

// use Slack formatting
Expand Down
2 changes: 1 addition & 1 deletion internal/notifier/matrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type MatrixPayload struct {
func NewMatrix(serverURL, token, roomId string, certPool *x509.CertPool) (*Matrix, error) {
_, err := url.ParseRequestURI(serverURL)
if err != nil {
return nil, fmt.Errorf("invalid Matrix homeserver URL %s", serverURL)
return nil, fmt.Errorf("invalid Matrix homeserver URL %s: '%w'", serverURL, err)
}

return &Matrix{
Expand Down
2 changes: 1 addition & 1 deletion internal/notifier/opsgenie.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type OpsgenieAlert struct {
func NewOpsgenie(hookURL string, proxyURL string, certPool *x509.CertPool, token string) (*Opsgenie, error) {
_, err := url.ParseRequestURI(hookURL)
if err != nil {
return nil, fmt.Errorf("invalid Opsgenie hook URL %s", hookURL)
return nil, fmt.Errorf("invalid Opsgenie hook URL %s: '%w'", hookURL, err)
}

if token == "" {
Expand Down
2 changes: 1 addition & 1 deletion internal/notifier/rocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type Rocket struct {
func NewRocket(hookURL string, proxyURL string, certPool *x509.CertPool, username string, channel string) (*Rocket, error) {
_, err := url.ParseRequestURI(hookURL)
if err != nil {
return nil, fmt.Errorf("invalid Rocket hook URL %s", hookURL)
return nil, fmt.Errorf("invalid Rocket hook URL %s: '%w'", hookURL, err)
}

if username == "" {
Expand Down
2 changes: 1 addition & 1 deletion internal/notifier/slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type SlackField struct {
func NewSlack(hookURL string, proxyURL string, token string, certPool *x509.CertPool, username string, channel string) (*Slack, error) {
_, err := url.ParseRequestURI(hookURL)
if err != nil {
return nil, fmt.Errorf("invalid Slack hook URL %s", hookURL)
return nil, fmt.Errorf("invalid Slack hook URL %s: '%w'", hookURL, err)
}

return &Slack{
Expand Down
2 changes: 1 addition & 1 deletion internal/notifier/teams.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type MSTeamsField struct {
func NewMSTeams(hookURL string, proxyURL string, certPool *x509.CertPool) (*MSTeams, error) {
_, err := url.ParseRequestURI(hookURL)
if err != nil {
return nil, fmt.Errorf("invalid MS Teams webhook URL %s", hookURL)
return nil, fmt.Errorf("invalid MS Teams webhook URL %s: '%w'", hookURL, err)
}

return &MSTeams{
Expand Down
2 changes: 1 addition & 1 deletion internal/notifier/webex.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func NewWebex(hookURL, proxyURL string, certPool *x509.CertPool, channel string,

_, err := url.ParseRequestURI(hookURL)
if err != nil {
return nil, fmt.Errorf("invalid Webex hook URL %s", hookURL)
return nil, fmt.Errorf("invalid Webex hook URL %s: '%w'", hookURL, err)
}

return &Webex{
Expand Down

0 comments on commit a395873

Please sign in to comment.