1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

ClouDNS: Return API error only when body unmarshals to errorResponse (#875)

This commit is contained in:
Pieter Maene
2020-09-29 13:23:14 +02:00
committed by GitHub
parent f082ad36c8
commit 683ed698e9

View File

@@ -212,12 +212,10 @@ func (c *api) get(endpoint string, params requestParams) ([]byte, error) {
// Got error from API ?
var errResp errorResponse
err = json.Unmarshal(bodyString, &errResp)
if err != nil {
return []byte{}, err
}
if errResp.Status == "Failed" {
return bodyString, fmt.Errorf("ClouDNS API error: %s URL:%s%s ", errResp.Description, req.Host, req.URL.RequestURI())
if err == nil {
if errResp.Status == "Failed" {
return bodyString, fmt.Errorf("ClouDNS API error: %s URL:%s%s ", errResp.Description, req.Host, req.URL.RequestURI())
}
}
return bodyString, nil