You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bug #47216 [Translation] Crowdin provider throw Exception when status 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
if (200 !== $statusCode = $response->getStatusCode()) {
265
285
$this->logger->error(sprintf('Unable to update file in Crowdin for file ID "%d" and domain "%s": "%s".', $fileId, $domain, $response->getContent(false)));
266
286
287
+
if (500 <= $statusCode) {
288
+
thrownewProviderException(sprintf('Unable to update file in Crowdin for file ID "%d" and domain "%s".', $fileId, $domain), $response);
289
+
}
290
+
267
291
returnnull;
268
292
}
269
293
@@ -324,9 +348,7 @@ private function listStrings(int $fileId, int $limit, int $offset): array
324
348
]);
325
349
326
350
if (200 !== $response->getStatusCode()) {
327
-
$this->logger->error(sprintf('Unable to list strings for file %d: "%s".', $fileId, $response->getContent()));
328
-
329
-
return [];
351
+
thrownewProviderException(sprintf('Unable to list strings for file "%d".', $fileId), $response);
0 commit comments