[folks] TpfPersona: throw PropertyError when an error occure changing group membership



commit f516257d5892d4114151d7e7c751d7396b7daaf9
Author: Xavier Claessens <xavier claessens collabora co uk>
Date:   Tue Apr 10 17:01:29 2012 +0200

    TpfPersona: throw PropertyError when an error occure changing group membership
    
    https://bugzilla.gnome.org/show_bug.cgi?id=630822

 backends/telepathy/lib/tpf-persona-store.vala |   23 ++++++++++++++++++-----
 backends/telepathy/lib/tpf-persona.vala       |    1 +
 2 files changed, 19 insertions(+), 5 deletions(-)
---
diff --git a/backends/telepathy/lib/tpf-persona-store.vala b/backends/telepathy/lib/tpf-persona-store.vala
index 660f6d8..1410cc9 100644
--- a/backends/telepathy/lib/tpf-persona-store.vala
+++ b/backends/telepathy/lib/tpf-persona-store.vala
@@ -1040,14 +1040,27 @@ public class Tpf.PersonaStore : Folks.PersonaStore
     }
 
   internal async void _change_group_membership (Folks.Persona persona,
-      string group, bool is_member)
+      string group, bool is_member) throws Folks.PropertyError
     {
       var tp_persona = (Tpf.Persona) persona;
 
-      if (is_member)
-        tp_persona.contact.add_to_group_async (group);
-      else
-        tp_persona.contact.remove_from_group_async (group);
+      try
+        {
+          if (is_member)
+            {
+              yield tp_persona.contact.add_to_group_async (group);
+            }
+          else
+            {
+              yield tp_persona.contact.remove_from_group_async (group);
+            }
+        }
+      catch (GLib.Error e)
+        {
+          /* Translators: the parameter is an error message. */
+          throw new PropertyError.UNKNOWN_ERROR (
+              _("Failed to change group membership: %s"), e.message);
+        }
     }
 
   /**
diff --git a/backends/telepathy/lib/tpf-persona.vala b/backends/telepathy/lib/tpf-persona.vala
index ffef795..a3675ee 100644
--- a/backends/telepathy/lib/tpf-persona.vala
+++ b/backends/telepathy/lib/tpf-persona.vala
@@ -417,6 +417,7 @@ public class Tpf.Persona : Folks.Persona,
    * See { link Folks.GroupDetails.change_group}.
    */
   public async void change_group (string group, bool is_member)
+      throws Folks.PropertyError
     {
       if (this._change_group (group, is_member))
         {



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