From 2c97549581b4970aab18eee8b8d4a9f4bf4f334f Mon Sep 17 00:00:00 2001 From: jackspirou Date: Fri, 20 Nov 2015 21:09:59 -0600 Subject: [PATCH] adding info on http error response --- main.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/main.go b/main.go index 69219ca..6764414 100644 --- a/main.go +++ b/main.go @@ -125,6 +125,17 @@ func main() { // debug print fmt.Printf("[debug] Webhook %d\n URL: %s\n METHOD: %s\n HEADERS: %s\n REQUEST BODY: %s\n RESPONSE STATUS: %s\n RESPONSE BODY: %s\n", i+1, req.URL, req.Method, req.Header, string(b), resp.Status, string(body)) + + } else if resp.StatusCode >= http.StatusBadRequest { + + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + // I do not think we need to os.Exit(1) if we are + // unable to read a http response body. + fmt.Printf("Error reading http response body. %s\n", err) + } + + fmt.Printf("[info] Webhook %d\n URL: %s\n RESPONSE STATUS: %s\n RESPONSE BODY: %s\n", i+1, req.URL, resp.Status, string(body)) } } }