jenkins-bot has submitted this change and it was merged.

Change subject: Show JSON parse error
......................................................................


Show JSON parse error

Bug: T148504
Change-Id: I0b6d5e93d5cd911db8d319c85318f06aa89f655f
---
M wikibase/queryService/api/Sparql.js
1 file changed, 22 insertions(+), 23 deletions(-)

Approvals:
  Smalyshev: Looks good to me, approved
  Addshore: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/wikibase/queryService/api/Sparql.js 
b/wikibase/queryService/api/Sparql.js
index 98bf89f..2d5d5b0 100644
--- a/wikibase/queryService/api/Sparql.js
+++ b/wikibase/queryService/api/Sparql.js
@@ -146,11 +146,11 @@
                        self._rawData = data;
 
                        deferred.resolve();
-               } ).fail( function( request ) {
+               } ).fail( function( request, options, exception ) {
                        self._executionTime = null;
                        self._rawData = null;
                        self._resultLength = null;
-                       self._generateErrorMessage( request );
+                       self._generateErrorMessage( request, options, exception 
);
 
                        deferred.reject();
                } );
@@ -163,36 +163,35 @@
         */
        SELF.prototype._generateErrorMessage = function( request, options, 
exception ) {
                var error = {
-                       code: null,
+                       code: ERROR_CODES.UNKNOWN,
                        message: null,
                        debug: request.responseText
                };
 
-               if ( request.status === 0 ) {
+               if ( request.status === 0 || exception ) {
                        error.code = ERROR_CODES.SERVER;
-                       error.message = exception;
-               } else {
+                       error.message = exception.message;
+               }
 
-                       try {
-                               var errorToMatch = error.debug.substring( 
error.debug
-                                               .indexOf( 
'java.util.concurrent.ExecutionException:' ) );
+               try {//extract error from server response
+                       var errorToMatch = error.debug.substring( error.debug
+                                       .indexOf( 
'java.util.concurrent.ExecutionException:' ) );
 
-                               for ( var errorKey in ERROR_MAP ) {
-                                       if ( errorToMatch.indexOf( errorKey ) 
!== -1 ) {
-                                               error.code = ERROR_MAP[ 
errorKey ];
-                                       }
+                       for ( var errorKey in ERROR_MAP ) {
+                               if ( errorToMatch.indexOf( errorKey ) !== -1 ) {
+                                       error.code = ERROR_MAP[ errorKey ];
+                                       error.message = null;
                                }
-
-                               if ( error.code === null || error.code === 
ERROR_CODES.MALFORMED ) {
-                                       error.message = error.debug
-                                                       .match(
-                                                                       
/(java\.util\.concurrent\.ExecutionException\:)+(.*)(Exception\:)+(.*)/ )
-                                                       .pop().trim();
-                               }
-
-                       } catch ( e ) {
-                               error.code = ERROR_CODES.UNKNOWN;
                        }
+
+                       if ( error.code === ERROR_CODES.UNKNOWN || error.code 
=== ERROR_CODES.MALFORMED ) {
+                               error.message = error.debug
+                                               .match(
+                                                               
/(java\.util\.concurrent\.ExecutionException\:)+(.*)(Exception\:)+(.*)/ )
+                                               .pop().trim();
+                       }
+
+               } catch ( e ) {
                }
 
                this._error = error;

-- 
To view, visit https://gerrit.wikimedia.org/r/316579
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I0b6d5e93d5cd911db8d319c85318f06aa89f655f
Gerrit-PatchSet: 1
Gerrit-Project: wikidata/query/gui
Gerrit-Branch: master
Gerrit-Owner: Jonas Kress (WMDE) <jonas.kr...@wikimedia.de>
Gerrit-Reviewer: Addshore <addshorew...@gmail.com>
Gerrit-Reviewer: Smalyshev <smalys...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to