[gnome-contacts] Catch some unhandled errors and print warnings



commit fe2fa59bf2cd0cc072ee08e982dd2a301f8065f6
Author: Philip Withnall <philip tecnocode co uk>
Date:   Sun Aug 4 09:57:13 2013 +0200

    Catch some unhandled errors and print warnings
    
    It may be desirable to propagate these errors further (to the UI),
    but printing warnings will do for now.

 src/contacts-app.vala           |   10 +++++++---
 src/contacts-contact-sheet.vala |    6 +++++-
 src/contacts-linking.vala       |   19 ++++++++++++++++---
 3 files changed, 28 insertions(+), 7 deletions(-)
---
diff --git a/src/contacts-app.vala b/src/contacts-app.vala
index 225429a..89866ad 100644
--- a/src/contacts-app.vala
+++ b/src/contacts-app.vala
@@ -155,9 +155,13 @@ public class Contacts.App : Gtk.Application {
   }
 
   public void show_help () {
-    Gtk.show_uri (window.get_screen (),
-         "help:gnome-help/contacts",
-         Gtk.get_current_event_time ());
+    try {
+      Gtk.show_uri (window.get_screen (),
+           "help:gnome-help/contacts",
+           Gtk.get_current_event_time ());
+    } catch (GLib.Error e1) {
+      warning ("Error showing help: %s", e1.message);
+    }
   }
 
   public void show_about () {
diff --git a/src/contacts-contact-sheet.vala b/src/contacts-contact-sheet.vala
index dcfcee4..a25a29c 100644
--- a/src/contacts-contact-sheet.vala
+++ b/src/contacts-contact-sheet.vala
@@ -174,7 +174,11 @@ public class Contacts.ContactSheet : Grid {
        foreach (var url in url_details.urls) {
          var button = add_row_with_button (ref i, _("Website"), Contact.format_uri_link_text (url));
          button.clicked.connect (() => {
-             Gtk.show_uri (null, url.value, 0);
+             try {
+               Gtk.show_uri (null, url.value, 0);
+             } catch (GLib.Error e1) {
+               warning ("Error opening website ā€˜%sā€™: %s", url.value, e1.message);
+             }
            });
        }
       }
diff --git a/src/contacts-linking.vala b/src/contacts-linking.vala
index 2a3f44e..e864c18 100644
--- a/src/contacts-linking.vala
+++ b/src/contacts-linking.vala
@@ -743,11 +743,19 @@ namespace Contacts {
        }
       }
       if (ind != null) {
-       yield App.app.contacts_store.aggregator.unlink_individual (ind);
+        try {
+         yield App.app.contacts_store.aggregator.unlink_individual (ind);
+       } catch (GLib.Error e1) {
+         warning ("Error unlinking individual ā€˜%sā€™: %s", ind.id, e1.message);
+       }
       }
 
       foreach (var ps in old_personas_distribution) {
-       yield App.app.contacts_store.aggregator.link_personas (ps);
+        try {
+         yield App.app.contacts_store.aggregator.link_personas (ps);
+       } catch (GLib.Error e1) {
+         warning ("Error linking personas: %s", e1.message);
+       }
       }
     }
   }
@@ -762,7 +770,12 @@ namespace Contacts {
       operation.add_persona_set (ps);
     }
 
-    yield App.app.contacts_store.aggregator.link_personas (all_personas);
+    try {
+      yield App.app.contacts_store.aggregator.link_personas (all_personas);
+    } catch (GLib.Error e1) {
+      warning ("Error linking personas: %s", e1.message);
+    }
+
     return operation;
   }
 }


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