From 683ed698e98f4aeeabefbc154041558d5eaa91a4 Mon Sep 17 00:00:00 2001 From: Pieter Maene Date: Tue, 29 Sep 2020 13:23:14 +0200 Subject: [PATCH] ClouDNS: Return API error only when body unmarshals to errorResponse (#875) --- providers/cloudns/api.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/providers/cloudns/api.go b/providers/cloudns/api.go index a28d3a3bc..607cf304d 100644 --- a/providers/cloudns/api.go +++ b/providers/cloudns/api.go @@ -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