bridge: DBusException also transports the twisted failure condition

This commit is contained in:
souliane 2014-06-15 16:06:02 +02:00
commit bba25dd62d

View file

@ -57,6 +57,11 @@ class DeferredNotAsync(dbus.DBusException):
class GenericException(dbus.DBusException):
def __init__(self, twisted_error):
"""
@param twisted_error (Failure): instance of twisted Failure
@return: DBusException
"""
super(GenericException, self).__init__()
try:
# twisted_error.value is a class
@ -64,7 +69,11 @@ class GenericException(dbus.DBusException):
except TypeError:
# twisted_error.value is an instance
class_ = twisted_error.value.__class__
self.args = (twisted_error.getErrorMessage(),)
message = twisted_error.getErrorMessage()
try:
self.args = (message, twisted_error.value.condition)
except AttributeError:
self.args = (message,)
self._dbus_error_name = '.'.join([const_ERROR_PREFIX, class_.__module__, class_.__name__])