Index: trunk/extensions/UploadWizard/UploadWizard.i18n.php |
— | — | @@ -31,7 +31,34 @@ |
32 | 32 | 'mwe-upwiz-step-deeds' => 'Release rights', |
33 | 33 | 'mwe-upwiz-step-details' => 'Describe', |
34 | 34 | 'mwe-upwiz-step-thanks' => 'Use', |
35 | | - 'mwe-upwiz-api-error-code' => 'API error code: $1', |
| 35 | + 'mwe-upwiz-api-error-http' => 'There a problem connecting to the service.', |
| 36 | + 'mwe-upwiz-api-error-ok-but-empty' => 'The server didn\'t return any information about the upload.', |
| 37 | + 'mwe-upwiz-api-error-unknown-code' => 'The server returned an error we did not understand: "$1"', |
| 38 | + 'mwe-upwiz-api-error-uploaddisabled' => 'Uploading is disabled on this wiki.', |
| 39 | + 'mwe-upwiz-api-error-nomodule' => 'The wiki did not know how to handle this upload.', |
| 40 | + 'mwe-upwiz-api-error-mustbeposted' => 'There\'s a bug in this software; it\'s not using the proper HTTP method.', |
| 41 | + 'mwe-upwiz-api-error-badaccess-groups' => 'You aren\'t permitted to upload files to this wiki. Check what access groups you belong to.', |
| 42 | + 'mwe-upwiz-api-error-stashfailed' => 'The wiki could not store the file.', |
| 43 | + 'mwe-upwiz-api-error-missingresult' => 'We could not determine if the copy succeeded.', |
| 44 | + 'mwe-upwiz-api-error-missingparam' => 'The upload didn\'t have all the required information (probably a bug in this uploader.)', |
| 45 | + 'mwe-upwiz-api-error-invalid-session-key' => 'The server couldn\'t find that file in your uploaded files.', |
| 46 | + 'mwe-upwiz-api-error-copyuploaddisabled' => 'Uploads by copying are disabled.', |
| 47 | + 'mwe-upwiz-api-error-mustbeloggedin' => 'You are not properly logged in.', |
| 48 | + 'mwe-upwiz-api-error-empty-file' => 'The file you submitted was empty.', |
| 49 | + 'mwe-upwiz-api-error-file-too-large' => 'The file you submitted was too large.', |
| 50 | + 'mwe-upwiz-api-error-filetype-missing' => 'The file is missing an extension.', |
| 51 | + 'mwe-upwiz-api-error-filetype-banned' => 'This type of file is banned.', |
| 52 | + 'mwe-upwiz-api-error-filename-tooshort' => 'The filename is too short.', |
| 53 | + 'mwe-upwiz-api-error-illegal-filename' => 'The filename is not allowed.', |
| 54 | + 'mwe-upwiz-api-error-verification-error' => 'This file might be corrupt, or have the wrong extension.', |
| 55 | + 'mwe-upwiz-api-error-hookaborted' => 'The modification you tried to make was aborted by an extension hook.', |
| 56 | + 'mwe-upwiz-api-error-unknown-error' => 'Something (we don\'t know what) went wrong when trying to upload your file.', |
| 57 | + 'mwe-upwiz-api-error-internal-error' => 'Something went wrong with processing your upload on the wiki.', |
| 58 | + 'mwe-upwiz-api-error-overwrite' => 'Overwriting an existing file is not allowed.', |
| 59 | + 'mwe-upwiz-api-error-badtoken' => 'The "token" we use to identify you to the server was bad.', |
| 60 | + 'mwe-upwiz-api-error-fetchfileerror' => 'Something went wrong while fetching the file.', |
| 61 | + 'mwe-upwiz-api-warning-duplicate' => 'There is another file already on the wiki with the same content', |
| 62 | + 'mwe-upwiz-api-warning-exists' => 'There is another file already on the wiki with the same filename', |
36 | 63 | 'mwe-upwiz-tutorial-error-localized-file-missing' => 'Sorry, we could not find a tutorial in your language. The English one is shown instead.', |
37 | 64 | 'mwe-upwiz-tutorial-error-file-missing' => 'Sorry, we could not find any files for the tutorial that is supposed to go here. Please contact the system administrators.', |
38 | 65 | 'mwe-upwiz-tutorial-error-cannot-transform' => 'Sorry, we could not get a scaled image of the tutorial to fit this screen. This may be a temporary problem with Wikimedia Commons; try again later.', |
Index: trunk/extensions/UploadWizard/resources/mw.Api.js |
— | — | @@ -126,13 +126,13 @@ |
127 | 127 | ajaxOptions.data = parameters; |
128 | 128 | |
129 | 129 | ajaxOptions.error = function( xhr, textStatus, exception ) { |
130 | | - ajaxOptions.err( 'http-' + textStatus, { xhr: xhr, exception: exception } ); |
| 130 | + ajaxOptions.err( 'http', { xhr: xhr, textStatus: textStatus, exception: exception } ); |
131 | 131 | }; |
132 | 132 | |
133 | 133 | /* success just means 200 OK; also check for output and API errors */ |
134 | 134 | ajaxOptions.success = function( result ) { |
135 | 135 | if ( mw.isEmpty( result ) ) { |
136 | | - ajaxOptions.err( "empty", "OK response but empty result (check HTTP headers?)" ); |
| 136 | + ajaxOptions.err( "ok-but-empty", "OK response but empty result (check HTTP headers?)" ); |
137 | 137 | } else if ( result.error ) { |
138 | 138 | var code = mw.isDefined( result.error.code ) ? result.error.code : "unknown"; |
139 | 139 | ajaxOptions.err( code, result ); |
— | — | @@ -145,6 +145,48 @@ |
146 | 146 | |
147 | 147 | } |
148 | 148 | |
149 | | - } |
| 149 | + }; |
150 | 150 | |
| 151 | + /** |
| 152 | + * This is a list of errors we might receive from the API. |
| 153 | + * For now, this just documents our expectation that there should be similar messages |
| 154 | + * available. |
| 155 | + */ |
| 156 | + mw.Api.errors = [ |
| 157 | + 'uploaddisabled', |
| 158 | + 'nomodule', |
| 159 | + 'mustbeposted', |
| 160 | + 'badaccess-groups', |
| 161 | + 'stashfailed', |
| 162 | + 'missingresult', |
| 163 | + 'missingparam', |
| 164 | + 'invalid-session-key', |
| 165 | + 'copyuploaddisabled', |
| 166 | + 'mustbeloggedin', |
| 167 | + 'empty-file', |
| 168 | + 'file-too-large', |
| 169 | + 'filetype-missing', |
| 170 | + 'filetype-banned', |
| 171 | + 'filename-tooshort', |
| 172 | + 'illegal-filename', |
| 173 | + 'verification-error', |
| 174 | + 'hookaborted', |
| 175 | + 'unknown-error', |
| 176 | + 'internal-error', |
| 177 | + 'overwrite', |
| 178 | + 'badtoken', |
| 179 | + 'fetchfileerror' |
| 180 | + ]; |
| 181 | + |
| 182 | + /** |
| 183 | + * This is a list of warnings we might receive from the API. |
| 184 | + * For now, this just documents our expectation that there should be similar messages |
| 185 | + * available. |
| 186 | + */ |
| 187 | + |
| 188 | + mw.Api.warnings = [ |
| 189 | + 'duplicate', |
| 190 | + 'exists' |
| 191 | + ]; |
| 192 | + |
151 | 193 | }) ( window.mw, jQuery ); |
Index: trunk/extensions/UploadWizard/resources/combined.js |
— | — | @@ -5837,13 +5837,13 @@ |
5838 | 5838 | ajaxOptions.data = parameters; |
5839 | 5839 | |
5840 | 5840 | ajaxOptions.error = function( xhr, textStatus, exception ) { |
5841 | | - ajaxOptions.err( 'http-' + textStatus, { xhr: xhr, exception: exception } ); |
| 5841 | + ajaxOptions.err( 'http', { xhr: xhr, textStatus: textStatus, exception: exception } ); |
5842 | 5842 | }; |
5843 | 5843 | |
5844 | 5844 | /* success just means 200 OK; also check for output and API errors */ |
5845 | 5845 | ajaxOptions.success = function( result ) { |
5846 | 5846 | if ( mw.isEmpty( result ) ) { |
5847 | | - ajaxOptions.err( "empty", "OK response but empty result (check HTTP headers?)" ); |
| 5847 | + ajaxOptions.err( "ok-but-empty", "OK response but empty result (check HTTP headers?)" ); |
5848 | 5848 | } else if ( result.error ) { |
5849 | 5849 | var code = mw.isDefined( result.error.code ) ? result.error.code : "unknown"; |
5850 | 5850 | ajaxOptions.err( code, result ); |
— | — | @@ -5856,8 +5856,50 @@ |
5857 | 5857 | |
5858 | 5858 | } |
5859 | 5859 | |
5860 | | - } |
| 5860 | + }; |
5861 | 5861 | |
| 5862 | + /** |
| 5863 | + * This is a list of errors we might receive from the API. |
| 5864 | + * For now, this just documents our expectation that there should be similar messages |
| 5865 | + * available. |
| 5866 | + */ |
| 5867 | + mw.Api.errors = [ |
| 5868 | + 'uploaddisabled', |
| 5869 | + 'nomodule', |
| 5870 | + 'mustbeposted', |
| 5871 | + 'badaccess-groups', |
| 5872 | + 'stashfailed', |
| 5873 | + 'missingresult', |
| 5874 | + 'missingparam', |
| 5875 | + 'invalid-session-key', |
| 5876 | + 'copyuploaddisabled', |
| 5877 | + 'mustbeloggedin', |
| 5878 | + 'empty-file', |
| 5879 | + 'file-too-large', |
| 5880 | + 'filetype-missing', |
| 5881 | + 'filetype-banned', |
| 5882 | + 'filename-tooshort', |
| 5883 | + 'illegal-filename', |
| 5884 | + 'verification-error', |
| 5885 | + 'hookaborted', |
| 5886 | + 'unknown-error', |
| 5887 | + 'internal-error', |
| 5888 | + 'overwrite', |
| 5889 | + 'badtoken', |
| 5890 | + 'fetchfileerror' |
| 5891 | + ]; |
| 5892 | + |
| 5893 | + /** |
| 5894 | + * This is a list of warnings we might receive from the API. |
| 5895 | + * For now, this just documents our expectation that there should be similar messages |
| 5896 | + * available. |
| 5897 | + */ |
| 5898 | + |
| 5899 | + mw.Api.warnings = [ |
| 5900 | + 'duplicate', |
| 5901 | + 'exists' |
| 5902 | + ]; |
| 5903 | + |
5862 | 5904 | }) ( window.mw, jQuery ); |
5863 | 5905 | // library to assist with edits |
5864 | 5906 | |
— | — | @@ -8005,7 +8047,7 @@ |
8006 | 8048 | _this.$form.submit(); |
8007 | 8049 | }; |
8008 | 8050 | var err = function( code, info ) { |
8009 | | - _this.upload.setFailed( code, info ); |
| 8051 | + _this.upload.setError( code, info ); |
8010 | 8052 | }; |
8011 | 8053 | this.configureEditToken( ok, err ); |
8012 | 8054 | } |
— | — | @@ -9202,7 +9244,6 @@ |
9203 | 9245 | * Stop the upload -- we have failed for some reason |
9204 | 9246 | */ |
9205 | 9247 | setError: function( code, info ) { |
9206 | | - /* stop the upload progress */ |
9207 | 9248 | this.state = 'error'; |
9208 | 9249 | this.transportProgress = 0; |
9209 | 9250 | this.ui.showError( code, info ); |
— | — | @@ -9584,11 +9625,21 @@ |
9585 | 9626 | |
9586 | 9627 | /** |
9587 | 9628 | * Show that transport has failed |
| 9629 | + * @param String code: error code from API |
| 9630 | + * @param {String|Object} info: extra info |
9588 | 9631 | */ |
9589 | 9632 | showError: function( code, info ) { |
9590 | | - // XXX TODO use code |
9591 | 9633 | this.showIndicator( 'error' ); |
9592 | | - // create a status message for the error |
| 9634 | + // is this an error that we expect to have a message for? |
| 9635 | + var msgKey = 'mwe-upwiz-api-error-unknown-code' |
| 9636 | + var args = [ code ]; |
| 9637 | + if ( $j.inArray( code, mw.Api.errors ) !== -1 ) { |
| 9638 | + var msgKey = 'mwe-upwiz-api-error-' + code; |
| 9639 | + // args may change base on particular error messages. |
| 9640 | + // for instance, we are throwing away the extra info right now. Might be nice to surface that in a debug mode |
| 9641 | + args = []; |
| 9642 | + } |
| 9643 | + this.setStatus( msgKey, args ); |
9593 | 9644 | }, |
9594 | 9645 | |
9595 | 9646 | /** |
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizard.js |
— | — | @@ -82,7 +82,6 @@ |
83 | 83 | * Stop the upload -- we have failed for some reason |
84 | 84 | */ |
85 | 85 | setError: function( code, info ) { |
86 | | - /* stop the upload progress */ |
87 | 86 | this.state = 'error'; |
88 | 87 | this.transportProgress = 0; |
89 | 88 | this.ui.showError( code, info ); |
— | — | @@ -464,11 +463,21 @@ |
465 | 464 | |
466 | 465 | /** |
467 | 466 | * Show that transport has failed |
| 467 | + * @param String code: error code from API |
| 468 | + * @param {String|Object} info: extra info |
468 | 469 | */ |
469 | 470 | showError: function( code, info ) { |
470 | | - // XXX TODO use code |
471 | 471 | this.showIndicator( 'error' ); |
472 | | - // create a status message for the error |
| 472 | + // is this an error that we expect to have a message for? |
| 473 | + var msgKey = 'mwe-upwiz-api-error-unknown-code' |
| 474 | + var args = [ code ]; |
| 475 | + if ( $j.inArray( code, mw.Api.errors ) !== -1 ) { |
| 476 | + var msgKey = 'mwe-upwiz-api-error-' + code; |
| 477 | + // args may change base on particular error messages. |
| 478 | + // for instance, we are throwing away the extra info right now. Might be nice to surface that in a debug mode |
| 479 | + args = []; |
| 480 | + } |
| 481 | + this.setStatus( msgKey, args ); |
473 | 482 | }, |
474 | 483 | |
475 | 484 | /** |
Index: trunk/extensions/UploadWizard/resources/mw.ApiUploadHandler.js |
— | — | @@ -114,7 +114,7 @@ |
115 | 115 | _this.$form.submit(); |
116 | 116 | }; |
117 | 117 | var err = function( code, info ) { |
118 | | - _this.upload.setFailed( code, info ); |
| 118 | + _this.upload.setError( code, info ); |
119 | 119 | }; |
120 | 120 | this.configureEditToken( ok, err ); |
121 | 121 | } |
Index: trunk/extensions/UploadWizard/resources/combined.min.js |
— | — | @@ -5837,13 +5837,13 @@ |
5838 | 5838 | ajaxOptions.data=parameters; |
5839 | 5839 | |
5840 | 5840 | ajaxOptions.error=function(xhr,textStatus,exception){ |
5841 | | -ajaxOptions.err('http-'+textStatus,{xhr:xhr,exception:exception}); |
| 5841 | +ajaxOptions.err('http',{xhr:xhr,textStatus:textStatus,exception:exception}); |
5842 | 5842 | }; |
5843 | 5843 | |
5844 | 5844 | |
5845 | 5845 | ajaxOptions.success=function(result){ |
5846 | 5846 | if(mw.isEmpty(result)){ |
5847 | | -ajaxOptions.err("empty","OK response but empty result (check HTTP headers?)"); |
| 5847 | +ajaxOptions.err("ok-but-empty","OK response but empty result (check HTTP headers?)"); |
5848 | 5848 | }else if(result.error){ |
5849 | 5849 | var code=mw.isDefined(result.error.code)?result.error.code:"unknown"; |
5850 | 5850 | ajaxOptions.err(code,result); |
— | — | @@ -5856,8 +5856,50 @@ |
5857 | 5857 | |
5858 | 5858 | } |
5859 | 5859 | |
5860 | | -} |
| 5860 | +}; |
5861 | 5861 | |
| 5862 | + |
| 5863 | + |
| 5864 | + |
| 5865 | + |
| 5866 | + |
| 5867 | +mw.Api.errors=[ |
| 5868 | +'uploaddisabled', |
| 5869 | +'nomodule', |
| 5870 | +'mustbeposted', |
| 5871 | +'badaccess-groups', |
| 5872 | +'stashfailed', |
| 5873 | +'missingresult', |
| 5874 | +'missingparam', |
| 5875 | +'invalid-session-key', |
| 5876 | +'copyuploaddisabled', |
| 5877 | +'mustbeloggedin', |
| 5878 | +'empty-file', |
| 5879 | +'file-too-large', |
| 5880 | +'filetype-missing', |
| 5881 | +'filetype-banned', |
| 5882 | +'filename-tooshort', |
| 5883 | +'illegal-filename', |
| 5884 | +'verification-error', |
| 5885 | +'hookaborted', |
| 5886 | +'unknown-error', |
| 5887 | +'internal-error', |
| 5888 | +'overwrite', |
| 5889 | +'badtoken', |
| 5890 | +'fetchfileerror' |
| 5891 | +]; |
| 5892 | + |
| 5893 | + |
| 5894 | + |
| 5895 | + |
| 5896 | + |
| 5897 | + |
| 5898 | + |
| 5899 | +mw.Api.warnings=[ |
| 5900 | +'duplicate', |
| 5901 | +'exists' |
| 5902 | +]; |
| 5903 | + |
5862 | 5904 | })(window.mw,jQuery); |
5863 | 5905 | |
5864 | 5906 | |
— | — | @@ -8005,7 +8047,7 @@ |
8006 | 8048 | _this.$form.submit(); |
8007 | 8049 | }; |
8008 | 8050 | var err=function(code,info){ |
8009 | | -_this.upload.setFailed(code,info); |
| 8051 | +_this.upload.setError(code,info); |
8010 | 8052 | }; |
8011 | 8053 | this.configureEditToken(ok,err); |
8012 | 8054 | } |
— | — | @@ -9202,7 +9244,6 @@ |
9203 | 9245 | |
9204 | 9246 | |
9205 | 9247 | setError:function(code,info){ |
9206 | | - |
9207 | 9248 | this.state='error'; |
9208 | 9249 | this.transportProgress=0; |
9209 | 9250 | this.ui.showError(code,info); |
— | — | @@ -9585,10 +9626,20 @@ |
9586 | 9627 | |
9587 | 9628 | |
9588 | 9629 | |
| 9630 | + |
| 9631 | + |
9589 | 9632 | showError:function(code,info){ |
9590 | | - |
9591 | 9633 | this.showIndicator('error'); |
9592 | 9634 | |
| 9635 | +var msgKey='mwe-upwiz-api-error-unknown-code' |
| 9636 | +var args=[code]; |
| 9637 | +if($j.inArray(code,mw.Api.errors)!==-1){ |
| 9638 | +var msgKey='mwe-upwiz-api-error-'+code; |
| 9639 | + |
| 9640 | + |
| 9641 | +args=[]; |
| 9642 | +} |
| 9643 | +this.setStatus(msgKey,args); |
9593 | 9644 | }, |
9594 | 9645 | |
9595 | 9646 | |