Jonas Kress (WMDE) has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/276459

Change subject: Display short error and fix error marker
......................................................................

Display short error and fix error marker

Change-Id: I637f6531eab74a056fd683feebb5bac0efbff847
---
M index.html
M style.css
M wikibase/queryService/ui/App.js
M wikibase/queryService/ui/editor/Editor.js
4 files changed, 30 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikidata/query/gui 
refs/changes/59/276459/1

diff --git a/index.html b/index.html
index 723cc13..b41e86b 100644
--- a/index.html
+++ b/index.html
@@ -129,6 +129,9 @@
                        <div class="actionMessage panel-heading label 
label-info">Action</div>
                </div>
                <div class="row">
+                       <div id="query-error-short" class="panel-heading label 
label-danger">Error</div>
+               </div>
+               <div class="row">
                        <div id="query-error" class="panel-heading">Test 
error</div>
                </div>
 
diff --git a/style.css b/style.css
index 07728aa..7711556 100644
--- a/style.css
+++ b/style.css
@@ -15,7 +15,7 @@
        display: none;
 }
 
-#query-error {
+#query-error, #query-error-short {
        display: none;
 }
 
diff --git a/wikibase/queryService/ui/App.js b/wikibase/queryService/ui/App.js
index c3ce269..714aa03 100644
--- a/wikibase/queryService/ui/App.js
+++ b/wikibase/queryService/ui/App.js
@@ -335,17 +335,35 @@
                $( '.actionMessage' ).show();
                $( '.actionMessage' ).text( 'Running query...' );
                $( '#execute-button' ).prop('disabled', true);
+               $( '#query-error' ).hide();
+               $( '#query-error-short' ).hide();
+
 
                this._sparqlApi.query( this._editor.getValue() )
                .done( $.proxy( this._handleQueryResult, this ) )
                .fail(function(){
-                       $( '.actionMessage' ).hide();
-                       $( '#query-error' ).html( $( '<pre>' ).text( 
self._sparqlApi.getErrorMessage() ) ).show();
-                       $( '#execute-button' ).prop('disabled', false);
-                       self._editor.highlightError( 
self._sparqlApi.getErrorMessage() );
+                       self._handleQueryError( 
self._sparqlApi.getErrorMessage() );
                } );
 
                $( '.queryUri' ).attr( 'href',self._sparqlApi.getQueryUri() );
+       };
+
+
+       /**
+        * @private
+        **/
+       SELF.prototype._handleQueryError = function( error ) {
+               $( '.actionMessage' ).hide();
+               $( '#query-error' ).html( $( '<pre>' ).text( error ) ).show();
+
+               try {
+                       var shortError = error.split( 
'java.util.concurrent.ExecutionException:' )[1].split( '\n' )[0].split( 
'Exception:' ).pop();
+                       $( '#query-error-short' ).show().text( shortError );
+               } catch (e) {}
+
+               $( '#execute-button' ).prop('disabled', false);
+
+               this._editor.highlightError( error );
        };
 
        /**
@@ -358,7 +376,6 @@
                $( '#query-time' ).text( api.getExecutionTime() );
                $( '.query-total' ).show();
                $( '.actionMessage' ).hide();
-               $( '#query-error' ).hide();
                $( '#execute-button' ).prop('disabled', false);
 
                var $queryResult = $( '#query-result' ),
diff --git a/wikibase/queryService/ui/editor/Editor.js 
b/wikibase/queryService/ui/editor/Editor.js
index fcfd22d..fc9d731 100644
--- a/wikibase/queryService/ui/editor/Editor.js
+++ b/wikibase/queryService/ui/editor/Editor.js
@@ -173,6 +173,10 @@
                        // highlight character at error position
                        line = match[1] - 1;
                        character = match[2] - 1;
+                       if( character >= this._editor.doc.getLine( line 
).length -1 ){
+                               character =  this._editor.doc.getLine( line 
).length -1 ;
+                       }
+
                        ERROR_LINE_MARKER = this._editor.doc.markText(
                                { 'line': line, 'ch': 0 },
                                { 'line': line },

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I637f6531eab74a056fd683feebb5bac0efbff847
Gerrit-PatchSet: 1
Gerrit-Project: wikidata/query/gui
Gerrit-Branch: master
Gerrit-Owner: Jonas Kress (WMDE) <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to