mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-01-12 10:27:57 +08:00
ClouDNS: Return API error only when body unmarshals to errorResponse (#875)
This commit is contained in:
parent
f082ad36c8
commit
683ed698e9
1 changed files with 4 additions and 6 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue