优化代码

This commit is contained in:
GoEdgeLab
2022-04-19 12:58:00 +08:00
parent f5a40b6956
commit 682240a202
4 changed files with 24 additions and 22 deletions

View File

@@ -279,15 +279,15 @@ func (this *CloudFlareProvider) doAPI(method string, apiPath string, args map[st
return errors.New("invalid response status '" + strconv.Itoa(resp.StatusCode) + "', response '" + string(data) + "'")
}
err = json.Unmarshal(data, respPtr)
if err != nil {
return err
}
if resp.StatusCode != http.StatusOK {
return errors.New("response error: " + string(data))
}
err = json.Unmarshal(data, respPtr)
if err != nil {
return errors.New("decode json failed: " + err.Error() + ", response text: " + string(data))
}
return nil
}