Skip to content

Commit

Permalink
Handle network errors
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxSem committed Aug 27, 2019
1 parent d767e5b commit 52a79d4
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"not-found": "The file you requested could not be found. Please pick another image.",
"invalid-format": "Only SVG files are supported.",
"invalid-svg": "Error reading file.",
"network-error": "Error getting information from Wikimedia servers. Please try again later.",

"pick-another": "← pick another file",
"view-on-commons": "View on Commons",
Expand Down
1 change: 1 addition & 0 deletions i18n/qqq.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"not-found": "Error message displayed if the requested file could not be found.",
"invalid-format": "Error message displayed if the requested file is not an SVG image.",
"invalid-svg": "Error message displayed if the requested file is an SVG image but software can't interpret it.",
"network-error": "Error message displayed if request to Wikimedia servers fails.",
"pick-another": "Label for backlink from the translate page to the search page.",
"view-on-commons": "Link to view the file on Commons. The whole phrase is linked.",
"opens-in-new-tab": "Tooltip text for links that will open in a new browser tab.",
Expand Down
1 change: 1 addition & 0 deletions public/assets/i18n/app/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"not-found": "The file you requested could not be found. Please pick another image.",
"invalid-format": "Only SVG files are supported.",
"invalid-svg": "Error reading file.",
"network-error": "Error getting information from Wikimedia servers. Please try again later.",

"pick-another": "← pick another file",
"view-on-commons": "View on Commons",
Expand Down
1 change: 1 addition & 0 deletions public/assets/i18n/app/qqq.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"not-found": "Error message displayed if the requested file could not be found.",
"invalid-format": "Error message displayed if the requested file is not an SVG image.",
"invalid-svg": "Error message displayed if the requested file is an SVG image but software can't interpret it.",
"network-error": "Error message displayed if request to Wikimedia servers fails.",
"pick-another": "Label for backlink from the translate page to the search page.",
"view-on-commons": "Link to view the file on Commons. The whole phrase is linked.",
"opens-in-new-tab": "Tooltip text for links that will open in a new browser tab.",
Expand Down
3 changes: 3 additions & 0 deletions src/Controller/TranslateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use App\OOUI\TranslationsFieldset;
use App\Service\FileCache;
use App\Service\Uploader;
use GuzzleHttp\Exception\RequestException;
use Krinkle\Intuition\Intuition;
use OOUI\ButtonInputWidget;
use OOUI\DropdownInputWidget;
Expand Down Expand Up @@ -66,6 +67,8 @@ public function translate(
return $this->showError('invalid-format', $normalizedFilename);
} catch (SvgLoadException $exception) {
return $this->showError('invalid-svg', $normalizedFilename);
} catch (RequestException $exception) {
return $this->showError('network-error', $normalizedFilename);
}

// If there are no strings to translate, tell the user.
Expand Down

0 comments on commit 52a79d4

Please sign in to comment.