From 517f442fa34f283671b96ee028aac5c23d9371bd Mon Sep 17 00:00:00 2001 From: NicoMen Date: Wed, 30 May 2018 20:26:07 +0200 Subject: [PATCH] Add details to the cloudflare error message (#452) --- providers/dns/cloudflare/cloudflare.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/providers/dns/cloudflare/cloudflare.go b/providers/dns/cloudflare/cloudflare.go index 7cc32faf..2904bde6 100644 --- a/providers/dns/cloudflare/cloudflare.go +++ b/providers/dns/cloudflare/cloudflare.go @@ -7,6 +7,7 @@ import ( "encoding/json" "fmt" "io" + "io/ioutil" "net/http" "os" "strings" @@ -205,7 +206,11 @@ func (c *DNSProvider) makeRequest(method, uri string, body io.Reader) (json.RawM } return nil, fmt.Errorf("Cloudflare API Error \n%s", errStr) } - return nil, fmt.Errorf("Cloudflare API error") + strBody := "Unreadable body" + if body, err := ioutil.ReadAll(resp.Body); err == nil { + strBody= string(body) + } + return nil, fmt.Errorf("Cloudflare API error. The request %s sent a response with a body which is not in JSON format : %s\n", req.URL.String(), strBody) } return r.Result, nil