Skip to content

Commit

Permalink
fix(shoutrrr): display errors on init failure (#558)
Browse files Browse the repository at this point in the history
  • Loading branch information
piksel authored May 29, 2020
1 parent 86b1b04 commit 70bd4e2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion pkg/notifications/notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ func NewNotifier(c *cobra.Command) *Notifier {
default:
log.Fatalf("Unknown notification type %q", t)
}
n.types = append(n.types, tn)
if tn != nil {
n.types = append(n.types, tn)
}
}

return n
Expand Down
10 changes: 8 additions & 2 deletions pkg/notifications/shoutrrr.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ func newShoutrrrNotifier(c *cobra.Command, acceptedLogLevels []log.Level) t.Noti
flags := c.PersistentFlags()

urls, _ := flags.GetStringArray("notification-url")
r, _ := shoutrrr.CreateSender(urls...)
r, err := shoutrrr.CreateSender(urls...)
if err != nil {
fmt.Printf("Failed to initialize Shoutrrr notifications: %s\n", err.Error())
return nil
}

n := &shoutrrrTypeNotifier{
Urls: urls,
Expand All @@ -52,8 +56,10 @@ func (e *shoutrrrTypeNotifier) buildMessage(entries []*log.Entry) string {
}

func (e *shoutrrrTypeNotifier) sendEntries(entries []*log.Entry) {
// Do the sending in a separate goroutine so we don't block the main process.

msg := e.buildMessage(entries)

// Do the sending in a separate goroutine so we don't block the main process.
go func() {
errs := e.Router.Send(msg, nil)

Expand Down

0 comments on commit 70bd4e2

Please sign in to comment.