[Translation] Crowdin provider throw Exception when status is 50x#47216
Closed
alamirault wants to merge 0 commit into
Closed
[Translation] Crowdin provider throw Exception when status is 50x#47216alamirault wants to merge 0 commit into
alamirault wants to merge 0 commit into
Conversation
alamirault
commented
Aug 7, 2022
| ]); | ||
|
|
||
| if (200 !== $response->getStatusCode()) { | ||
| $this->logger->error(sprintf('Unable to list strings for file %d: "%s".', $fileId, $response->getContent())); |
Contributor
Author
There was a problem hiding this comment.
$throw flag to getContent is true by default. So this warning cannot work with codes 3xx, 4xx, 5xx.
And only 200 is possible in 2xx (https://developer.crowdin.com/api/v2/#operation/api.projects.strings.getMany)
476084b to
df11ec7
Compare
welcoMattic
approved these changes
Aug 8, 2022
Member
welcoMattic
left a comment
There was a problem hiding this comment.
Thanks for this fix. I guess it's a good way to do. So, if you want, fee free to open new PRs for 2 other providers.
Member
|
Let’s do everything in this PR of possible. |
alamirault
commented
Aug 8, 2022
| $response = $this->client->request('POST', sprintf('tags/%s.json', rawurlencode($tag)), [ | ||
| 'body' => implode(',', $idsWithoutComma), | ||
| ]); | ||
| if ([] !== $idsWithoutComma) { |
Contributor
Author
There was a problem hiding this comment.
Avoid calling provider when idsWithoutComma is empty. There is no asset to tag so I think is ok 😊
Contributor
Author
|
Also done for Loco and Lokalise providers. |
fabpot
approved these changes
Aug 9, 2022
Member
|
Thank you @alamirault. |
fabpot
added a commit
that referenced
this pull request
Aug 9, 2022
… is 50x (alamirault) This PR was squashed before being merged into the 5.4 branch. Discussion ---------- [Translation] Crowdin provider throw Exception when status is 50x | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | Fix #45920 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> When calling provider return server error, it was silently accepted (with warning log in some cases). Now, `ProviderException` is thrown. This avoid `[OK] New local translations has been sent` when there is one failed call. Only Crowdin provider is changed here. If it's right approach, I can edit this PR or create new one foreach provider Commits ------- 3b7aed2 [Translation] Crowdin provider throw Exception when status is 50x
06cfab4 to
3b7aed2
Compare
This was referenced Aug 26, 2022
Merged
Merged
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When calling provider return server error, it was silently accepted (with warning log in some cases).
Now,
ProviderExceptionis thrown. This avoid[OK] New local translations has been sentwhen there is one failed call.Only Crowdin provider is changed here. If it's right approach, I can edit this PR or create new one foreach provider