[gnome-documents] all: show an error box for controller query errors



commit bdc89ca15d93c69836aa5be194a8e80d901ac7ef
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Aug 29 16:59:08 2011 -0400

    all: show an error box for controller query errors

 src/error.js             |    7 +++++++
 src/mainWindow.js        |    9 +++++++++
 src/trackerController.js |   16 +++++++---------
 3 files changed, 23 insertions(+), 9 deletions(-)
---
diff --git a/src/error.js b/src/error.js
index d7ca594..7c5e3d0 100644
--- a/src/error.js
+++ b/src/error.js
@@ -37,6 +37,13 @@ ErrorHandler.prototype = {
         log('Error caught: ' + message + ' - ' + exception.toString());
 
         this.emit('load-error', message, exception);
+    },
+
+    addQueryError: function(exception) {
+        let message = _("Unable to fetch the list of documents");
+        log('Error caught: ' + message + ' - ' + exception.toString());
+
+        this.emit('query-error', message, exception);
     }
 };
 Signals.addSignalMethods(ErrorHandler.prototype);
diff --git a/src/mainWindow.js b/src/mainWindow.js
index e7baa6c..ceb36f2 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -70,6 +70,8 @@ MainWindow.prototype = {
 
         Global.settings.connect('changed::list-view',
                                 Lang.bind(this, this._refreshViewSettings));
+        Global.errorHandler.connect('query-error',
+                                    Lang.bind(this, this._onQueryError));
         Global.errorHandler.connect('load-error',
                                     Lang.bind(this, this._onLoadError));
 
@@ -240,5 +242,12 @@ MainWindow.prototype = {
 
         let errorBox = new ErrorBox.ErrorBox(message, exception.toString());
         this._scrolledWin.add_with_viewport(errorBox.widget);
+    },
+
+    _onQueryError: function(manager, message, exception) {
+        this._destroyView();
+
+        let errorBox = new ErrorBox.ErrorBox(message, exception.toString());
+        this._scrolledWin.add_with_viewport(errorBox.widget);
     }
 };
diff --git a/src/trackerController.js b/src/trackerController.js
index acac433..4785bff 100644
--- a/src/trackerController.js
+++ b/src/trackerController.js
@@ -81,8 +81,11 @@ TrackerController.prototype = {
         return false;
     },
 
-    _onQueryFinished: function() {
+    _onQueryFinished: function(exception) {
         Global.selectionController.freezeSelection(false);
+
+        if (exception)
+            Global.errorHandler.addQueryError(exception);
     },
 
     _onCursorNext: function(cursor, res, addCount) {
@@ -91,14 +94,11 @@ TrackerController.prototype = {
 
             if (!valid) {
                 // signal the total count update and return
-                this._onQueryFinished();
+                this._onQueryFinished(null);
                 return;
             }
         } catch (e) {
-            // FIXME: error handling
-            log('Unable to fetch results from cursor: ' + e.toString());
-            this._onQueryFinished();
-
+            this._onQueryFinished(e);
             return;
         }
 
@@ -114,9 +114,7 @@ TrackerController.prototype = {
             let cursor = object.query_finish(res);
             cursor.next_async(null, Lang.bind(this, this._onCursorNext, true));
         } catch (e) {
-            // FIXME: error handling
-            log('Unable to execute query: ' + e.toString());
-            this._onQueryFinished();
+            this._onQueryFinished(e);
         }
     },
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]