Skip to content

Commit

Permalink
updated slack's error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
darkcrux committed Nov 14, 2014
1 parent 6d16eea commit 958ca60
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion notifier/slack-notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"bytes"
"fmt"

"io/ioutil"

"encoding/json"
"net/http"

Expand Down Expand Up @@ -51,7 +53,12 @@ func (slack *SlackNotifier) Notify(messages Messages) bool {
log.Println("Unable to send data to slack:", err)
return false
} else {
res.Body.Close()
defer res.Body.Close()
statusCode := res.StatusCode
if statusCode != 200 {
body, err := ioutil.ReadAll(res.Body)
log.Println("Unable to notify slack:", body, err)
}
log.Println("Slack notification sent.")
return true
}
Expand Down

0 comments on commit 958ca60

Please sign in to comment.