ClouDNS: Return API error only when body unmarshals to errorResponse
@@ -212,13 +212,11 @@ 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 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
}
