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:
@@ -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
|
||||
|
Reference in New Issue
Block a user