[gnome-documents] Use logError() when logging exceptions



commit 3c3fff5048812ca8f5561048a02d6adafd74f00f
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Sat Nov 26 16:16:00 2016 +0100

    Use logError() when logging exceptions
    
    It will also print out a nice JS stacktrace when doing so.

 src/application.js         |   18 +++++++++---------
 src/changeMonitor.js       |    2 +-
 src/documents.js           |   24 ++++++++++++------------
 src/evinceview.js          |    2 +-
 src/notifications.js       |    4 ++--
 src/overview.js            |    2 +-
 src/search.js              |    2 +-
 src/selections.js          |   10 +++++-----
 src/sharing.js             |   14 +++++++-------
 src/shellSearchProvider.js |   14 +++++++-------
 src/trackerUtils.js        |    6 +++---
 11 files changed, 49 insertions(+), 49 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index b0db381..9091162 100644
--- a/src/application.js
+++ b/src/application.js
@@ -156,7 +156,7 @@ const Application = new Lang.Class({
                                 try {
                                     manager.index_file_finish(res);
                                 } catch (e) {
-                                    log('Error indexing the getting started PDF: ' + e.message);
+                                    logError(e, 'Error indexing the getting started PDF');
                                 }
                             });
                     } catch (e) {
@@ -198,7 +198,7 @@ const Application = new Lang.Class({
                          'help:gnome-documents',
                          Gtk.get_current_event_time());
         } catch (e) {
-            log('Unable to display help: ' + e.message);
+            logError(e, 'Unable to display help');
         }
     },
 
@@ -254,7 +254,7 @@ const Application = new Lang.Class({
 
                 if (error) {
                     if (!error.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
-                        log('Error updating the cache: ' + error.toString());
+                        logError(error, 'Error updating the cache');
 
                     return;
                 }
@@ -274,7 +274,7 @@ const Application = new Lang.Class({
                 // startup a refresh of the gdocs cache
                 this._refreshMinerNow(this.gdataMiner);
             } catch (e) {
-                log('Unable to start GData miner: ' + e.message);
+                logError(e, 'Unable to start GData miner');
             }
         }
 
@@ -283,7 +283,7 @@ const Application = new Lang.Class({
                 // startup a refresh of the owncloud cache
                 this._refreshMinerNow(this.owncloudMiner);
             } catch (e) {
-                log('Unable to start Owncloud miner: ' + e.message);
+                logError(e, 'Unable to start Owncloud miner');
             }
         }
 
@@ -292,7 +292,7 @@ const Application = new Lang.Class({
                 // startup a refresh of the skydrive cache
                 this._refreshMinerNow(this.zpjMiner);
             } catch (e) {
-                log('Unable to start Zpj miner: ' + e.message);
+                logError(e, 'Unable to start Zpj miner');
             }
         }
     },
@@ -368,7 +368,7 @@ const Application = new Lang.Class({
         try {
             connection = Tracker.SparqlConnection.get(null);
         } catch (e) {
-            log('Unable to connect to the tracker database: ' + e.toString());
+            logError(e, 'Unable to connect to the tracker database');
             return;
         }
 
@@ -376,7 +376,7 @@ const Application = new Lang.Class({
             try {
                 goaClient = Goa.Client.new_sync(null);
             } catch (e) {
-                log('Unable to create the GOA client: ' + e.toString());
+                logError(e, 'Unable to create the GOA client');
                 return;
             }
         }
@@ -430,7 +430,7 @@ const Application = new Lang.Class({
             this._extractPriority = TrackerExtractPriority();
             this._extractPriority.SetRdfTypesRemote(['nfo:Document']);
         } catch (e) {
-            log('Unable to connect to the tracker extractor: ' + e.toString());
+            logError(e, 'Unable to connect to the tracker extractor');
         }
 
         // start miners
diff --git a/src/changeMonitor.js b/src/changeMonitor.js
index 594a232..028f3dc 100644
--- a/src/changeMonitor.js
+++ b/src/changeMonitor.js
@@ -151,7 +151,7 @@ const TrackerChangeMonitor = new Lang.Class({
                         try {
                             valid = cursor.next_finish(res);
                         } catch(e) {
-                            log('Unable to resolve item URNs for graph changes ' + e.message);
+                            logError(e, 'Unable to resolve item URNs for graph changes');
                         }
 
                         if (valid) {
diff --git a/src/documents.js b/src/documents.js
index 504dbe4..d24c77c 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -64,7 +64,7 @@ const DeleteItemJob = new Lang.Class({
                 try {
                     object.update_finish(res);
                 } catch (e) {
-                    log(e);
+                    logError(e, 'Failed to delete resource ' + this._urn);
                 }
 
                 if (this._callback)
@@ -100,7 +100,7 @@ const CollectionIconWatcher = new Lang.Class({
                 try {
                     cursor = object.query_finish(res);
                 } catch (e) {
-                    log('Unable to query collection items ' + e.toString());
+                    logError(e, 'Unable to query collection items');
                     return;
                 }
 
@@ -114,7 +114,7 @@ const CollectionIconWatcher = new Lang.Class({
         try {
             valid = cursor.next_finish(res);
         } catch (e) {
-            log('Unable to query collection items ' + e.toString());
+            logError(e, 'Unable to query collection items');
             cursor.close();
             return;
         }
@@ -339,7 +339,7 @@ const DocCommon = new Lang.Class({
                 pixbuf = iconInfo.load_icon();
                 this._setOrigPixbuf(pixbuf);
             } catch (e) {
-                log('Unable to load pixbuf: ' + e.toString());
+                logError(e, 'Unable to load pixbuf');
             }
         }
     },
@@ -423,7 +423,7 @@ const DocCommon = new Lang.Class({
         try {
             info = object.query_info_finish(res);
         } catch (e) {
-            log('Unable to query info for file at ' + this.uri + ': ' + e.toString());
+            logError(e, 'Unable to query info for file at ' + this.uri);
             this._failedThumbnailing = true;
             return;
         }
@@ -454,7 +454,7 @@ const DocCommon = new Lang.Class({
         try {
             info = object.query_info_finish(res);
         } catch (e) {
-            log('Unable to query info for file at ' + this.uri + ': ' + e.toString());
+            logError(e, 'Unable to query info for file at ' + this.uri);
             this._failedThumbnailing = true;
             return;
         }
@@ -482,7 +482,7 @@ const DocCommon = new Lang.Class({
                                     let pixbuf = GdkPixbuf.Pixbuf.new_from_stream_finish(res);
                                     this._setOrigPixbuf(pixbuf);
                                 } catch (e) {
-                                    log('Unable to create pixbuf from ' + thumbFile.get_uri() + ': ' + 
e.toString());
+                                    logError(e, 'Unable to create pixbuf from ' + thumbFile.get_uri());
                                     this._failedThumbnailing = true;
                                     this._thumbPath = null;
                                     thumbFile.delete_async(GLib.PRIORITY_DEFAULT, null, null);
@@ -492,7 +492,7 @@ const DocCommon = new Lang.Class({
                                 stream.close_async(0, null, null);
                             }));
                 } catch (e) {
-                    log('Unable to read file at ' + thumbFile.get_uri() + ': ' + e.toString());
+                    logError(e, 'Unable to read file at ' + thumbFile.get_uri());
                     this._failedThumbnailing = true;
                     this._thumbPath = null;
                     thumbFile.delete_async(GLib.PRIORITY_DEFAULT, null, null);
@@ -554,7 +554,7 @@ const DocCommon = new Lang.Class({
 
                 emblemedPixbuf = iconInfo.load_icon();
             } catch (e) {
-                log('Unable to render the emblem: ' + e.toString());
+                logError(e, 'Unable to render the emblem');
             }
         }
 
@@ -635,7 +635,7 @@ const DocCommon = new Lang.Class({
             else
                 Gtk.show_uri(screen, this.uri, timestamp);
         } catch (e) {
-            log('Unable to show URI ' + this.uri + ': ' + e.toString());
+            logError(e, 'Unable to show URI ' + this.uri);
         }
     },
 
@@ -643,7 +643,7 @@ const DocCommon = new Lang.Class({
         this.load(null, null, Lang.bind(this,
             function(doc, docModel, error) {
                 if (error) {
-                    log('Unable to print document ' + this.uri + ': ' + error);
+                    logError(error, 'Unable to print document ' + this.uri);
                     return;
                 }
 
@@ -797,7 +797,7 @@ const LocalDocument = new Lang.Class({
                 try {
                     file.trash_finish(res);
                 } catch(e) {
-                    log('Unable to trash ' + this.uri + ': ' + e.message);
+                    logError(e, 'Unable to trash ' + this.uri);
                 }
             }));
     },
diff --git a/src/evinceview.js b/src/evinceview.js
index fc35cef..90d72e5 100644
--- a/src/evinceview.js
+++ b/src/evinceview.js
@@ -454,7 +454,7 @@ const EvinceView = new Lang.Class({
         try {
             Gio.AppInfo.launch_default_for_uri(uri, context);
         } catch (e) {
-            log('Unable to open external link: ' + e.message);
+            logError(e, 'Unable to open external link');
         }
     },
 
diff --git a/src/notifications.js b/src/notifications.js
index 834d079..4a8a7ee 100644
--- a/src/notifications.js
+++ b/src/notifications.js
@@ -181,8 +181,8 @@ const IndexingNotification = new Lang.Class({
             this._manager = TrackerControl.MinerManager.new_full(false);
             this._manager.connect('miner-progress', Lang.bind(this, this._checkNotification));
         } catch(e) {
-            log('Unable to create a TrackerMinerManager, indexing progress ' +
-                'notification won\'t work: ' + e.message);
+            logError(e, 'Unable to create a TrackerMinerManager, indexing progress ' +
+                     'notification won\'t work');
             return;
         }
 
diff --git a/src/overview.js b/src/overview.js
index b13a468..8fd00a9 100644
--- a/src/overview.js
+++ b/src/overview.js
@@ -326,7 +326,7 @@ const EmptyResultsBox = new Lang.Class({
 
                     app.launch([], ctx);
                 } catch(e) {
-                    log('Unable to launch gnome-control-center: ' + e.message);
+                    logError(e, 'Unable to launch gnome-control-center');
                 }
 
                 return true;
diff --git a/src/search.js b/src/search.js
index fac784f..1096204 100644
--- a/src/search.js
+++ b/src/search.js
@@ -583,7 +583,7 @@ const OffsetController = new Lang.Class({
                     try {
                         cursor = object.query_finish(res);
                     } catch (e) {
-                        log('Unable to execute count query: ' + e.toString());
+                        logError(e, 'Unable to execute count query');
                         return;
                     }
 
diff --git a/src/selections.js b/src/selections.js
index 1ce0c1b..d143b1b 100644
--- a/src/selections.js
+++ b/src/selections.js
@@ -61,7 +61,7 @@ const FetchCollectionsJob = new Lang.Class({
                     cursor = object.query_finish(res);
                     cursor.next_async(null, Lang.bind(this, this._onCursorNext));
                 } catch (e) {
-                    log('Unable to run FetchCollectionsJob: ' + e.message);
+                    logError(e, 'Unable to run FetchCollectionsJob');
                     this._emitCallback();
                 }
             }));
@@ -73,7 +73,7 @@ const FetchCollectionsJob = new Lang.Class({
         try {
             valid = cursor.next_finish(res);
         } catch (e) {
-            log('Unable to read results of FetchCollectionsJob: ' + e.message);
+            logError(e, 'Unable to read results of FetchCollectionsJob');
         }
 
         if (!valid) {
@@ -214,7 +214,7 @@ const UpdateMtimeJob = new Lang.Class({
                 try {
                     object.update_finish(res);
                 } catch (e) {
-                    log('Unable to run UpdateMtimeJob: ' + e.message);
+                    logError(e, 'Unable to run UpdateMtimeJob');
                 }
 
                 if (this._callback)
@@ -252,7 +252,7 @@ const SetCollectionForSelectionJob = new Lang.Class({
                         try {
                             object.update_finish(res);
                         } catch (e) {
-                            log('Unable to run SetCollectionForSelectionJob: ' + e.message);
+                            logError(e, 'Unable to run SetCollectionForSelectionJob');
                         }
 
                         this._jobCollector();
@@ -294,7 +294,7 @@ const CreateCollectionJob = new Lang.Class({
                 try {
                     variant = object.update_blank_finish(res); // variant is aaa{ss}
                 } catch (e) {
-                    log('Unable to run CreateCollectionJob: ' + e.message);
+                    logError(e, 'Unable to run CreateCollectionJob');
                 }
 
                 variant = variant.get_child_value(0); // variant is now aa{ss}
diff --git a/src/sharing.js b/src/sharing.js
index 9af15ab..56976a4 100644
--- a/src/sharing.js
+++ b/src/sharing.js
@@ -86,7 +86,7 @@ const SharingDialog = new Lang.Class({
         this._doc.createGDataEntry(null, Lang.bind(this,
             function(entry, service, exception) {
                 if (exception) {
-                    log("Error getting GData Entry " + exception.message);
+                    logError(exception, 'Error getting GData Entry');
                     return;
                 }
                 this._entry = entry;
@@ -344,7 +344,7 @@ const SharingDialog = new Lang.Class({
                     this._feed = this._service.query_finish(result);
                     this._getScopeRulesEntry();
                 } catch(e) {
-                    log("Error getting ACL Feed " + e.message);
+                    logError(e, 'Error getting ACL Feed');
                 }
             }));
     },
@@ -470,7 +470,7 @@ const SharingDialog = new Lang.Class({
                         this._service.insert_entry_finish(res);
                         this._refreshEntryACL();
                     } catch(e) {
-                        log("Error inserting new ACL rule " + e.message);
+                        logError(e, 'Error inserting new ACL rule');
                         this._showErrorDialog(_("The document was not updated"));
                     }
                 }));
@@ -506,7 +506,7 @@ const SharingDialog = new Lang.Class({
                         service.insert_entry_finish(res);
                         this._refreshEntryACL();
                     } catch(e) {
-                        log('Error inserting new ACL scope for document ' + e.message);
+                        logError(e, 'Error inserting new ACL scope for document');
                         this._showErrorDialog(_("The document was not updated"));
                     }
 
@@ -563,7 +563,7 @@ const SharingDialog = new Lang.Class({
                             service.update_entry_finish(res);
                             this._refreshEntryACL();
                         } catch(e) {
-                            log('Error updating ACL scope for document ' + e.message);
+                            logError(e, 'Error updating ACL scope for document');
                             this._showErrorDialog(_("The document was not updated"));
                         }
 
@@ -580,7 +580,7 @@ const SharingDialog = new Lang.Class({
                             service.delete_entry_finish(res);
                             this._refreshEntryACL();
                         } catch(e) {
-                            log('Error deleting ACL scope for document  ' + e.message);
+                            logError(e, 'Error deleting ACL scope for document');
                             this._showErrorDialog(_("The document was not updated"));
                         }
 
@@ -599,7 +599,7 @@ const SharingDialog = new Lang.Class({
                             // Workaround if the doc is shared with link: step 2 add the new public 
permisssion.
                             this._insertNewPermission(newScopeType, newRole);
                         } catch(e) {
-                            log('Error deleting ACL scope for document ' + e.message);
+                            logError(e, 'Error deleting ACL scope for document');
                             this._showErrorDialog(_("The document was not updated"));
                         }
                     }));
diff --git a/src/shellSearchProvider.js b/src/shellSearchProvider.js
index 0dd54f1..ee4f082 100644
--- a/src/shellSearchProvider.js
+++ b/src/shellSearchProvider.js
@@ -82,7 +82,7 @@ function _createThumbnailIcon(uri) {
         if (path)
             return new Gio.FileIcon({ file: Gio.file_new_for_path(path) });
     } catch(e) {
-        log('Unable to create thumbnail icon: ' + e.message);
+        logError(e, 'Unable to create thumbnail icon');
     }
     return null;
 }
@@ -141,7 +141,7 @@ const CreateCollectionIconJob = new Lang.Class({
                     cursor = object.query_finish(res);
                     cursor.next_async(null, Lang.bind(this, this._onCursorNext));
                 } catch (e) {
-                    log('Unable to run CreateCollectionIconJob: ' + e.message);
+                    logError(e, 'Unable to run CreateCollectionIconJob');
                     this._hasItemIds();
                 }
             }));
@@ -161,7 +161,7 @@ const CreateCollectionIconJob = new Lang.Class({
             try {
                 pixbuf = info.load_icon();
             } catch(e) {
-                log("Unable to load pixbuf: " + e.message);
+                logError(e, 'Unable to load pixbuf');
             }
         } else if (icon instanceof Gio.FileIcon) {
             try {
@@ -169,7 +169,7 @@ const CreateCollectionIconJob = new Lang.Class({
                 pixbuf = GdkPixbuf.Pixbuf.new_from_stream(stream,
                                                           null);
             } catch(e) {
-                log("Unable to load pixbuf: " + e.message);
+                logError(e, 'Unable to load pixbuf');
             }
         }
 
@@ -183,7 +183,7 @@ const CreateCollectionIconJob = new Lang.Class({
             valid = cursor.next_finish(res);
         } catch (e) {
             cursor.close();
-            log('Unable to read results of CreateCollectionIconJob: ' + e.message);
+            logError(e, 'Unable to read results of CreateCollectionIconJob');
 
             this._hasItemIds();
         }
@@ -320,7 +320,7 @@ const FetchIdsJob = new Lang.Class({
                     cursor = object.query_finish(res);
                     cursor.next_async(this._cancellable, Lang.bind(this, this._onCursorNext));
                 } catch (e) {
-                    log('Unable to run FetchIdsJob: ' + e.message);
+                    logError(e, 'Unable to run FetchIdsJob');
                     callback(this._ids);
                 }
             }));
@@ -333,7 +333,7 @@ const FetchIdsJob = new Lang.Class({
             valid = cursor.next_finish(res);
         } catch (e) {
             cursor.close();
-            log('Unable to read results of FetchIdsJob: ' + e.message);
+            logError(e, 'Unable to read results of FetchIdsJob');
 
             this._callback(this._ids);
         }
diff --git a/src/trackerUtils.js b/src/trackerUtils.js
index 97f2369..d85f475 100644
--- a/src/trackerUtils.js
+++ b/src/trackerUtils.js
@@ -31,7 +31,7 @@ function setEditedName(newTitle, docId, callback) {
             try {
                 object.update_finish(res);
             } catch (e) {
-                log('Unable to set the new title on ' + docId + ' to : ' + e.toString());
+                logError(e, 'Unable to set the new title on ' + docId + ' to ' + newTitle);
             }
 
             if (callback)
@@ -59,7 +59,7 @@ const SingleItemJob = new Lang.Class({
                     let cursor = object.query_finish(res);
                     cursor.next_async(null, Lang.bind(this, this._onCursorNext));
                 } catch (e) {
-                    log('Unable to query single item ' + e.message);
+                    logError(e, 'Unable to query single item');
                     this._emitCallback();
                 }
             }));
@@ -71,7 +71,7 @@ const SingleItemJob = new Lang.Class({
         try {
             valid = cursor.next_finish(res);
         } catch (e) {
-            log('Unable to query single item ' + e.message);
+            logError(e, 'Unable to query single item');
         }
 
         if (!valid) {


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