Handle exceptions
authorEnrico Zini <enrico@enricozini.org>
Sun, 6 Sep 2009 20:06:28 +0000 (21:06 +0100)
committerEnrico Zini <enrico@enricozini.org>
Sun, 6 Sep 2009 20:06:28 +0000 (21:06 +0100)
src/gps.vala

index 62bcdf787bb1af0567c4e8dcb283ffda3c11ffef..546fdcf9d67a439c436bb0c5f3ae98df5ba7228b 100644 (file)
@@ -48,14 +48,22 @@ public class GPS: zavai.Service
     public void power_cycle(bool aggressive)
     {
         // "Have you tried turning it off and on again?"
-        usage.SetResourcePolicy("GPS", "disabled");
+               try {
+            usage.SetResourcePolicy("GPS", "disabled");
+               } catch (GLib.Error e) {
+                       zavai.log.error(e.message);
+               }
         Thread.usleep(500000);
         if (aggressive)
             // Sometimes the GPS crashes because its state contains something
             // that makes it crash, so we need to remove the saved state or it
             // crashes again quite soon
             FileUtils.unlink("/var/lib/freesmartphone/ogpsd.pickle");
-        usage.SetResourcePolicy("GPS", "auto");
+               try {
+            usage.SetResourcePolicy("GPS", "auto");
+               } catch (GLib.Error e) {
+                       zavai.log.error(e.message);
+               }
     }
 
        /// Request GPS resource