[gnome-documents] error: use new gjs API to detect cancellations



commit 3f2c6a0c2769e51d98465f6919e1bef340fd2f2f
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Jun 11 10:33:18 2012 -0400

    error: use new gjs API to detect cancellations
    
    Instead of matching on the error string, now that this is supported in
    GJS.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=671169

 src/error.js |   17 ++++++-----------
 1 files changed, 6 insertions(+), 11 deletions(-)
---
diff --git a/src/error.js b/src/error.js
index 70a76f1..11f3e39 100644
--- a/src/error.js
+++ b/src/error.js
@@ -22,6 +22,7 @@
 const Lang = imports.lang;
 const Signals = imports.signals;
 
+const Gio = imports.gi.Gio;
 const _ = imports.gettext.gettext;
 
 const ErrorHandler = new Lang.Class({
@@ -31,25 +32,19 @@ const ErrorHandler = new Lang.Class({
     },
 
     addLoadError: function(doc, exception) {
-        // Translators: %s is the title of a document
-        let message = _("Unable to load \"%s\" for preview").format(doc.name);
-
-        // FIXME: we need support for error codes in GJS
-        if (exception.toString().indexOf('Operation was cancelled') != -1)
+        if (exception.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
             return;
 
-        log('Error caught: ' + message + ' - ' + exception.message);
-
+        // Translators: %s is the title of a document
+        let message = _("Unable to load \"%s\" for preview").format(doc.name);
         this.emit('load-error', message, exception);
     },
 
     addQueryError: function(exception) {
-        let message = _("Unable to fetch the list of documents");
-
-        // FIXME: we need support for error codes in GJS
-        if (exception.toString().indexOf('Operation was cancelled') != -1)
+        if (exception.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
             return;
 
+        let message = _("Unable to fetch the list of documents");
         this.emit('query-error', message, exception);
     }
 });



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