refactor: clean code

This commit is contained in:
Fu Diwei
2025-05-16 13:56:45 +08:00
parent dd2087b101
commit b15bf8ef98
17 changed files with 32 additions and 32 deletions

View File

@@ -71,7 +71,7 @@ func (c *Client) sendRequest(method string, path string, params interface{}) (*r
if err != nil {
return resp, fmt.Errorf("cdnfly api error: failed to send request: %w", err)
} else if resp.IsError() {
return resp, fmt.Errorf("cdnfly api error: unexpected status code: %d, resp: %s", resp.StatusCode(), resp.Body())
return resp, fmt.Errorf("cdnfly api error: unexpected status code: %d, resp: %s", resp.StatusCode(), resp.String())
}
return resp, nil
@@ -87,7 +87,7 @@ func (c *Client) sendRequestWithResult(method string, path string, params interf
}
if err := json.Unmarshal(resp.Body(), &result); err != nil {
return fmt.Errorf("cdnfly api error: failed to parse response: %w", err)
return fmt.Errorf("cdnfly api error: failed to unmarshal response: %w", err)
} else if errcode := result.GetCode(); errcode != "" && errcode != "0" {
return fmt.Errorf("cdnfly api error: code='%s', message='%s'", errcode, result.GetMessage())
}