error handling
This commit is contained in:
parent
eca266f58a
commit
5353570475
6
main.go
6
main.go
@ -81,19 +81,19 @@ func notify(ptch patch, url string) {
|
|||||||
|
|
||||||
payloadBytes, err := json.Marshal(data)
|
payloadBytes, err := json.Marshal(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// handle err
|
log.Fatalf("Can't create webhook notice; failing since that means drastic data format change")
|
||||||
}
|
}
|
||||||
body := bytes.NewReader(payloadBytes)
|
body := bytes.NewReader(payloadBytes)
|
||||||
|
|
||||||
req, err := http.NewRequest("POST", url, body)
|
req, err := http.NewRequest("POST", url, body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// handle err
|
log.Fatalf("Either POST was mispelled or couldn't create a context")
|
||||||
}
|
}
|
||||||
req.Header.Set("Content-Type", "application/json")
|
req.Header.Set("Content-Type", "application/json")
|
||||||
|
|
||||||
resp, err := http.DefaultClient.Do(req)
|
resp, err := http.DefaultClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// handle err
|
log.Println("error posting to webhook")
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user