comparison 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
comparison
equal deleted inserted replaced
1072:d123d61976c8 1073:f094583732de
55 _dbus_error_name = const_ERROR_PREFIX + ".DeferredNotAsync" 55 _dbus_error_name = const_ERROR_PREFIX + ".DeferredNotAsync"
56 56
57 57
58 class GenericException(dbus.DBusException): 58 class GenericException(dbus.DBusException):
59 def __init__(self, twisted_error): 59 def __init__(self, twisted_error):
60 """
61
62 @param twisted_error (Failure): instance of twisted Failure
63 @return: DBusException
64 """
60 super(GenericException, self).__init__() 65 super(GenericException, self).__init__()
61 try: 66 try:
62 # twisted_error.value is a class 67 # twisted_error.value is a class
63 class_ = twisted_error.value().__class__ 68 class_ = twisted_error.value().__class__
64 except TypeError: 69 except TypeError:
65 # twisted_error.value is an instance 70 # twisted_error.value is an instance
66 class_ = twisted_error.value.__class__ 71 class_ = twisted_error.value.__class__
67 self.args = (twisted_error.getErrorMessage(),) 72 message = twisted_error.getErrorMessage()
73 try:
74 self.args = (message, twisted_error.value.condition)
75 except AttributeError:
76 self.args = (message,)
68 self._dbus_error_name = '.'.join([const_ERROR_PREFIX, class_.__module__, class_.__name__]) 77 self._dbus_error_name = '.'.join([const_ERROR_PREFIX, class_.__module__, class_.__name__])
69 78
70 79
71 class DbusObject(dbus.service.Object): 80 class DbusObject(dbus.service.Object):
72 81