Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error messages for alert providers #375

Merged
merged 1 commit into from
May 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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