diff --git a/client/client.go b/client/client.go index a365541..a0755b2 100644 --- a/client/client.go +++ b/client/client.go @@ -114,20 +114,20 @@ func (ac *AlpaconClient) sendRequest(req *http.Request) ([]byte, error) { } defer resp.Body.Close() - body, err := io.ReadAll(resp.Body) + respBody, err := io.ReadAll(resp.Body) if err != nil { return nil, err } if req.Method == "POST" && (resp.StatusCode != http.StatusCreated && resp.StatusCode != http.StatusOK) { - return nil, fmt.Errorf("POST request failed: %s (%s)", resp.Status, string(body)) + return nil, errors.New(resp.Status + string(respBody)) } else if req.Method == "DELETE" && resp.StatusCode != http.StatusNoContent { - return nil, fmt.Errorf("DELETE request failed: %s (%s)", resp.Status, string(body)) + return nil, errors.New(resp.Status + string(respBody)) } else if resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusMultipleChoices { - return nil, fmt.Errorf("unexpected status code: %s (%s)", resp.Status, string(body)) + return nil, errors.New(resp.Status + string(respBody)) } - return body, nil + return respBody, nil } // Get Request to Alpacon Server diff --git a/cmd/ftp/cp.go b/cmd/ftp/cp.go index 8add7fb..85f41b6 100644 --- a/cmd/ftp/cp.go +++ b/cmd/ftp/cp.go @@ -67,7 +67,7 @@ func downloadFile(client *client.AlpaconClient, src string, dest string) { utils.CliError("Failed to download the file from server: %s", err) return } - utils.CliInfo("`%s` successfully downloaded from server `%s`", src, dest) + utils.CliInfo("Download request for %s to server %s successful. Verify in events (alpacon events).", src, dest) } func uploadFile(client *client.AlpaconClient, src []string, dest string) { @@ -75,5 +75,5 @@ func uploadFile(client *client.AlpaconClient, src []string, dest string) { if err != nil { utils.CliError("Failed to upload the file to server %s", err) } - utils.CliInfo("`%s` successfully uploaded to `%s` ", src, dest) + utils.CliInfo("Upload request for %s to %s successful. Verify in events (alpacon events).", src, dest) }