diff src/bridge/bridge_constructor/dbus_core_template.py @ 1073:f094583732de

bridge: DBusException also transports the twisted failure condition
author souliane <souliane@mailoo.org>
date Sun, 15 Jun 2014 16:06:02 +0200
parents 95758ef3faa8
children 069ad98b360d
line wrap: on
line diff
--- a/src/bridge/bridge_constructor/dbus_core_template.py	Sun Jun 15 00:18:28 2014 +0200
+++ b/src/bridge/bridge_constructor/dbus_core_template.py	Sun Jun 15 16:06:02 2014 +0200
@@ -57,6 +57,11 @@
 
 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 @@
         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__])