comparison src/bridge/DBus.py @ 751:1def5b7edf9f

core, bridge: better GenericException handling
author Goffi <goffi@goffi.org>
date Tue, 17 Dec 2013 00:56:39 +0100
parents d731ae066158
children f49945d728de
comparison
equal deleted inserted replaced
750:c8b9f675ac17 751:1def5b7edf9f
54 54
55 55
56 class GenericException(dbus.DBusException): 56 class GenericException(dbus.DBusException):
57 def __init__(self, twisted_error): 57 def __init__(self, twisted_error):
58 super(GenericException, self).__init__() 58 super(GenericException, self).__init__()
59 mess = twisted_error.getErrorMessage() 59 try:
60 self._dbus_error_name = const_ERROR_PREFIX + "." + (mess or str(twisted_error.__class__)) 60 error_name = str(twisted_error.value().__class__.__name__)
61 # twisted_error.value is a class
62 except TypeError:
63 # twisted_error.value is an instance
64 error_name = str(twisted_error.value.__class__.__name__)
65 self._dbus_error_name = const_ERROR_PREFIX + "." + error_name
61 66
62 67
63 class DbusObject(dbus.service.Object): 68 class DbusObject(dbus.service.Object):
64 69
65 def __init__(self, bus, path): 70 def __init__(self, bus, path):