changeset 23419:0565c227608d

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.
author Will Thompson <will.thompson@collabora.co.uk>
date Thu, 03 Jul 2008 15:38:49 +0000
parents ded0a9cf1785
children 0c66344d0ed5
files libpurple/purple-url-handler
diffstat 1 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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()