From d07b1054567feec2e50e0931c1bca8c3ebb8a1cd Mon Sep 17 00:00:00 2001 From: Mladen Jablanovic Date: Thu, 14 Dec 2023 13:54:59 +0100 Subject: [PATCH 1/3] feat(CLI): Improve push error display --- clients/cli/cmd/internal/push.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/clients/cli/cmd/internal/push.go b/clients/cli/cmd/internal/push.go index fa813e5a..54382164 100644 --- a/clients/cli/cmd/internal/push.go +++ b/clients/cli/cmd/internal/push.go @@ -3,6 +3,7 @@ package internal import ( "bufio" "encoding/json" + "errors" "fmt" "os" "path/filepath" @@ -150,6 +151,7 @@ func (source *Source) Push(client *phrase.APIClient, waitForResults bool, branch return err } + noErrors := true for _, localeFile := range localeFiles { print.NonBatchPrintf("Uploading %s... ", localeFile.RelPath()) @@ -167,6 +169,9 @@ func (source *Source) Push(client *phrase.APIClient, waitForResults bool, branch upload, err := source.uploadFile(client, localeFile, branch, tag) if err != nil { + if openapiError, ok := err.(phrase.GenericOpenAPIError); ok { + print.Warn("API response: %s", openapiError.Body()) + } return err } @@ -193,6 +198,8 @@ func (source *Source) Push(client *phrase.APIClient, waitForResults bool, branch print.Success("Successfully uploaded and processed %s.", localeFile.RelPath()) case "error": print.Failure("There was an error processing %s. Your changes were not saved online.", localeFile.RelPath()) + print.NonBatchPrintf("More info at: %s\n", upload.Url) + noErrors = false } } else { outputUpload(upload) @@ -202,6 +209,9 @@ func (source *Source) Push(client *phrase.APIClient, waitForResults bool, branch fmt.Fprintln(os.Stderr, strings.Repeat("-", 10)) } } + if !noErrors { + return errors.New("not_all_files_processed") + } return nil } From e0f82aa31b6c9f2c283e2b632c909cabc0bd5c51 Mon Sep 17 00:00:00 2001 From: Mladen Jablanovic Date: Thu, 14 Dec 2023 17:00:39 +0100 Subject: [PATCH 2/3] more descriptive error --- clients/cli/cmd/internal/push.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/cmd/internal/push.go b/clients/cli/cmd/internal/push.go index 54382164..c7af7612 100644 --- a/clients/cli/cmd/internal/push.go +++ b/clients/cli/cmd/internal/push.go @@ -210,7 +210,7 @@ func (source *Source) Push(client *phrase.APIClient, waitForResults bool, branch } } if !noErrors { - return errors.New("not_all_files_processed") + return errors.New("not all files were uploaded successfully") } return nil From 6c10980870c7e35912441e7da82e8be6f2d14c41 Mon Sep 17 00:00:00 2001 From: Mladen Jablanovic Date: Fri, 15 Dec 2023 09:26:54 +0100 Subject: [PATCH 3/3] new line --- clients/cli/cmd/internal/push.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/cli/cmd/internal/push.go b/clients/cli/cmd/internal/push.go index c7af7612..12ccd9cd 100644 --- a/clients/cli/cmd/internal/push.go +++ b/clients/cli/cmd/internal/push.go @@ -170,7 +170,7 @@ func (source *Source) Push(client *phrase.APIClient, waitForResults bool, branch upload, err := source.uploadFile(client, localeFile, branch, tag) if err != nil { if openapiError, ok := err.(phrase.GenericOpenAPIError); ok { - print.Warn("API response: %s", openapiError.Body()) + print.Warn("\nAPI response: %s", openapiError.Body()) } return err }