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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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
}