From a2b556ed562a3dd3aabe6de99399485a1bb6dc0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Dziewo=C5=84ski?= Date: Wed, 11 Dec 2019 01:33:39 +0100 Subject: [PATCH] ve.init.mw.DesktopArticleTarget: Remove dead error handling code The .statusText and .status properties belong to the XMLHttpRequest object, and are not present on the API response data object. I think these checks were left over "just in case" when this code was ported to use mw.Api instead of XMLHttpRequest directly. MediaWiki API should never return just 'error' as the error code. Change-Id: Iac6f721881b9405919d3397df6606e54f182bc59 --- .../ve.init.mw.DesktopArticleTarget.js | 41 ++++++++----------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js index 747e4a5ccf..34e911432a 100644 --- a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js +++ b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js @@ -682,33 +682,30 @@ ve.init.mw.DesktopArticleTarget.prototype.loadFail = function ( code, errorDetai } // Don't show an error if the load was manually aborted - // The response.status check here is to catch aborts triggered by navigation away from the page errorInfo = ve.getProp( errorDetails, 'error', 'info' ) || errorDetails; - if ( !errorDetails || errorDetails.statusText !== 'abort' ) { - if ( code === 'http' || code === 'error' ) { - if ( errorDetails && ( errorDetails.status || ( errorDetails.xhr && errorDetails.xhr.status ) ) ) { - confirmPromptMessage = ve.msg( - 'visualeditor-loadwarning', - ve.msg( 'visualeditor-error-http', errorDetails.status || errorDetails.xhr.status ) - ); - } else { - confirmPromptMessage = ve.msg( - 'visualeditor-loadwarning', - ve.msg( 'visualeditor-error-noconnect' ) - ); - } - } else if ( errorInfo ) { + if ( code === 'http' ) { + if ( errorDetails && errorDetails.xhr && errorDetails.xhr.status ) { confirmPromptMessage = ve.msg( 'visualeditor-loadwarning', - code + ve.msg( 'colon-separator' ) + errorInfo + ve.msg( 'visualeditor-error-http', errorDetails.xhr.status ) ); - } else if ( typeof errorDetails === 'string' ) { - confirmPromptMessage = errorDetails; } else { - // At least give the devs something to work from - confirmPromptMessage = JSON.stringify( errorDetails ); + confirmPromptMessage = ve.msg( + 'visualeditor-loadwarning', + ve.msg( 'visualeditor-error-noconnect' ) + ); } + } else if ( errorInfo ) { + confirmPromptMessage = ve.msg( + 'visualeditor-loadwarning', + code + ve.msg( 'colon-separator' ) + errorInfo + ); + } else if ( typeof errorDetails === 'string' ) { + confirmPromptMessage = errorDetails; + } else { + // At least give the devs something to work from + confirmPromptMessage = JSON.stringify( errorDetails ); } if ( confirmPromptMessage ) { @@ -727,9 +724,7 @@ ve.init.mw.DesktopArticleTarget.prototype.loadFail = function ( code, errorDetai } } ); } else { - if ( errorDetails.statusText !== 'abort' ) { - mw.log.warn( 'Failed to find error message', code, errorDetails ); - } + mw.log.warn( 'Failed to find error message', code, errorDetails ); this.tryTeardown( true ); } };