-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Translation] Crowdin provider throw Exception when status is 50x #47216
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
[Translation] Crowdin provider throw Exception when status is 50x #47216
Conversation
@@ -324,9 +348,7 @@ private function listStrings(int $fileId, int $limit, int $offset): array | |||
]); | |||
|
|||
if (200 !== $response->getStatusCode()) { | |||
$this->logger->error(sprintf('Unable to list strings for file %d: "%s".', $fileId, $response->getContent())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Let’s do everything in this PR of possible. |
$response = $this->client->request('POST', sprintf('tags/%s.json', rawurlencode($tag)), [ | ||
'body' => implode(',', $idsWithoutComma), | ||
]); | ||
if ([] !== $idsWithoutComma) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid calling provider when idsWithoutComma
is empty. There is no asset to tag so I think is ok 😊
Also done for Loco and Lokalise providers. |
Thank you @alamirault. |
… 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
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