diff src/bridge/bridge_constructor/bridge_contructor.py @ 419:6c167a2e04b8

bridge: added generic D-Bus exception management + asyncCreateProfile method
author Goffi <goffi@goffi.org>
date Wed, 02 Nov 2011 22:47:59 +0100
parents 3646f6b9adb6
children 6c20c76abdcc
line wrap: on
line diff
--- a/src/bridge/bridge_constructor/bridge_contructor.py	Tue Nov 01 23:06:18 2011 +0100
+++ b/src/bridge/bridge_constructor/bridge_contructor.py	Wed Nov 02 22:47:59 2011 +0100
@@ -393,7 +393,7 @@
                 completion['args_result'] = self.getArguments(function['sig_in'], name=arg_doc, unicode_protect=self.options.unicode)
                 completion['async_comma'] = ', ' if async and function['sig_in'] else ''
                 completion['async_args_def'] = 'callback=None, errback=None' if async else ''
-                completion['async_args_call'] = 'callback, errback' if async else ''
+                completion['async_args_call'] = 'callback, lambda arg:errback(GenericException(arg))' if async else ''
                 completion['async_callbacks'] = "('callback', 'errback')" if async else "None"
                 methods_part.append("""\
     @dbus.service.method(const_INT_PREFIX+const_%(category)s_SUFFIX,
@@ -455,7 +455,7 @@
                 completion['args_result'] = self.getArguments(function['sig_in'], name=arg_doc)
                 completion['async_args'] = ', callback=None, errback=None' if async else ''
                 completion['async_comma'] = ', ' if async and function['sig_in'] else ''
-                completion['async_args_result'] = 'reply_handler=callback, error_handler=errback' if async else ''
+                completion['async_args_result'] = 'reply_handler=callback, error_handler=lambda err:errback(err._dbus_error_name[len(const_ERROR_PREFIX)+1:])' if async else ''
                 result = "self.db_%(category)s_iface.%(name)s(%(args_result)s%(async_comma)s%(async_args_result)s)" % completion
                 completion['result'] = ("unicode(%s)" if self.options.unicode and function['sig_out'] == 's' else "%s") % result
                 methods_part.append("""\