Matthias Mullie has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/362196 )
Change subject: Improve error messages for (known unknown) network errors
......................................................................
Improve error messages for (known unknown) network errors
Bug: T132611
Change-Id: I22f26e56e089edad7c423ac8f0007b5439de3e58
---
M includes/api/i18n/en.json
M includes/api/i18n/qqq.json
M resources/Resources.php
M resources/src/mediawiki/mediawiki.Upload.BookletLayout.js
4 files changed, 21 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/96/362196/1
diff --git a/includes/api/i18n/en.json b/includes/api/i18n/en.json
index 9ce10b9..3d4a100 100644
--- a/includes/api/i18n/en.json
+++ b/includes/api/i18n/en.json
@@ -1751,6 +1751,7 @@
"apierror-notarget": "You have not specified a valid target for this
action.",
"apierror-notpatrollable": "The revision r$1 can't be patrolled as it's
too old.",
"apierror-nouploadmodule": "No upload module set.",
+ "apierror-offline": "Could not proceed due to network connectivity
issues. Make sure you have a working internet connection and try again.",
"apierror-opensearch-json-warnings": "Warnings cannot be represented in
OpenSearch JSON format.",
"apierror-pagecannotexist": "Namespace doesn't allow actual pages.",
"apierror-pagedeleted": "The page has been deleted since you fetched
its timestamp.",
@@ -1801,6 +1802,7 @@
"apierror-stashzerolength": "File is of zero length, and could not be
stored in the stash: $1.",
"apierror-systemblocked": "You have been blocked automatically by
MediaWiki.",
"apierror-templateexpansion-notwikitext": "Template expansion is only
supported for wikitext content. $1 uses content model $2.",
+ "apierror-timeout": "The server did not respond within the expected
time.",
"apierror-toofewexpiries": "$1 expiry {{PLURAL:$1|timestamp
was|timestamps were}} provided where $2 {{PLURAL:$2|was|were}} needed.",
"apierror-unknownaction": "The action specified, <kbd>$1</kbd>, is not
recognized.",
"apierror-unknownerror-editpage": "Unknown EditPage error: $1.",
diff --git a/includes/api/i18n/qqq.json b/includes/api/i18n/qqq.json
index 27d10d5..04bcb88 100644
--- a/includes/api/i18n/qqq.json
+++ b/includes/api/i18n/qqq.json
@@ -1640,6 +1640,7 @@
"apierror-notarget": "{{doc-apierror}}",
"apierror-notpatrollable": "{{doc-apierror}}\n\nParameters:\n* $1 -
Revision ID number.",
"apierror-nouploadmodule": "{{doc-apierror}}",
+ "apierror-offline": "Error message for when files could not be uploaded
as a result of bad/lost internet connection.",
"apierror-opensearch-json-warnings": "{{doc-apierror}}",
"apierror-pagecannotexist": "{{doc-apierror}}",
"apierror-pagedeleted": "{{doc-apierror}}",
@@ -1690,6 +1691,7 @@
"apierror-stashzerolength": "{{doc-apierror}}\n\nParameters:\n* $1 -
Exception text. Currently this is probably English, hopefully we'll fix that in
the future.",
"apierror-systemblocked": "{{doc-apierror}}",
"apierror-templateexpansion-notwikitext":
"{{doc-apierror}}\n\nParameters:\n* $1 - Page title.\n* $2 - Content model.",
+ "apierror-timeout": "API error message that can be used for client side
localisation of API errors.",
"apierror-toofewexpiries": "{{doc-apierror}}\n\nParameters:\n* $1 -
Number provided.\n* $2 - Number needed.",
"apierror-unknownaction": "{{doc-apierror}}\n\nParameters:\n* $1 -
Action provided.",
"apierror-unknownerror-editpage": "{{doc-apierror}}\n\nParameters:\n*
$1 - Error code (an integer).",
diff --git a/resources/Resources.php b/resources/Resources.php
index dc05387..be04dab 100644
--- a/resources/Resources.php
+++ b/resources/Resources.php
@@ -1293,6 +1293,8 @@
'action-upload',
'apierror-mustbeloggedin',
'badaccess-groups',
+ 'apierror-timeout',
+ 'apierror-offline',
'apierror-unknownerror',
'api-error-unknown-warning',
'fileexists',
diff --git a/resources/src/mediawiki/mediawiki.Upload.BookletLayout.js
b/resources/src/mediawiki/mediawiki.Upload.BookletLayout.js
index 3fcbb3f..c58af4f 100644
--- a/resources/src/mediawiki/mediawiki.Upload.BookletLayout.js
+++ b/resources/src/mediawiki/mediawiki.Upload.BookletLayout.js
@@ -330,13 +330,26 @@
stateDetails = this.upload.getStateDetails(),
error = stateDetails.errors ? stateDetails.errors[ 0 ]
: false,
warnings = stateDetails.upload &&
stateDetails.upload.warnings,
- $ul = $( '<ul>' );
+ $ul = $( '<ul>' ),
+ errorText;
if ( state === mw.Upload.State.ERROR ) {
if ( !error ) {
+ if ( stateDetails.textStatus === 'timeout' ) {
+ // in case of $.ajax.fail(), there is
no response json
+ errorText = mw.message(
'apierror-timeout' ).parse();
+ } else if ( stateDetails.xhr &&
stateDetails.xhr.status === 0 ) {
+ // failed to even connect to server
+ errorText = mw.message(
'apierror-offline' ).parse();
+ } else if ( stateDetails.textStatus ) {
+ errorText = stateDetails.textStatus;
+ } else {
+ errorText = mw.message(
'apierror-unknownerror', JSON.stringify( stateDetails ) ).parse();
+ }
+
// If there's an 'exception' key, this might be
a timeout, or other connection problem
return $.Deferred().resolve( new OO.ui.Error(
- $( '<p>' ).msg(
'apierror-unknownerror', JSON.stringify( stateDetails ) ),
+ $( '<p>' ).html( errorText ),
{ recoverable: false }
) );
}
--
To view, visit https://gerrit.wikimedia.org/r/362196
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I22f26e56e089edad7c423ac8f0007b5439de3e58
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits