Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(CLI): Improve push error display [TSI-1736] #491

Merged
merged 3 commits into from
Dec 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions clients/cli/cmd/internal/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package internal
import (
"bufio"
"encoding/json"
"errors"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -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())

Expand All @@ -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("\nAPI response: %s", openapiError.Body())
}
return err
}

Expand All @@ -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)
Expand All @@ -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 were uploaded successfully")
}

return nil
}
Expand Down
Loading