Handle D-Bus errors more helpfully in purple-url-handler.

Thu, 03 Jul 2008 15:38:49 +0000

author
Will Thompson <resiak@pidgin.im>
date
Thu, 03 Jul 2008 15:38:49 +0000
changeset 23562
312323547538
parent 23561
f5ca68043e3f
child 23563
04877760aaf1

Handle D-Bus errors more helpfully in purple-url-handler.
If there's no libpurple object on the bus, then we'll never get to the uber
exception handler that previously swallowed all exceptions and suggested that
maybe no client is running.

libpurple/purple-url-handler file | annotate | diff | comparison | revisions
--- a/libpurple/purple-url-handler	Thu Jul 03 14:51:52 2008 +0000
+++ b/libpurple/purple-url-handler	Thu Jul 03 15:38:49 2008 +0000
@@ -6,7 +6,15 @@
 import time
 import urllib
 
-obj = dbus.SessionBus().get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject")
+bus = dbus.SessionBus()
+obj = None
+try:
+    obj = bus.get_object("im.pidgin.purple.PurpleService",
+                         "/im/pidgin/purple/PurpleObject")
+except dbus.DBusException, e:
+    if e._dbus_error_name == "org.freedesktop.DBus.Error.ServiceUnknown":
+        print "Error: no libpurple-powered client is running. Try starting Pidgin or Finch."
+        sys.exit(1)
 purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface")
 
 class CheckedObject:
@@ -328,9 +336,9 @@
             ymsgr(uri)
         else:
             print "Unknown protocol: %s" % type
-    except dbus.dbus_bindings.DBusException:
-        print "ERROR: Is there a libpurple-powered client (e.g. Pidgin or Finch) running?"
-
+    except dbus.DBusException, e:
+        print "Error: %s" % (e.message)
+        sys.exit(1)
 
 if __name__ == "__main__":
     main()

mercurial