Skip to content

Commit

Permalink
feat(CLI): Improve push error display [TSI-1736] (#491)
Browse files Browse the repository at this point in the history
  • Loading branch information
jablan authored Dec 15, 2023
1 parent 26a85d4 commit 555c017
Showing 1 changed file with 10 additions and 0 deletions.
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

0 comments on commit 555c017

Please sign in to comment.