[Dbus-cxx-users] RE : Feature request with patch proposal: propagate exceptions through DBus
Status: Beta
Brought to you by:
rvinyard
From: <emm...@or...> - 2013-10-08 15:36:27
|
Here you are. The patch is catching standard exceptions inside of DBus::Method<>::handle_call_message() within method.h (well, method.h.m4). That worked for me but there might be other places where the code needs updating (method_impl.h maybe? I couldn't find it included anywhere). On the proxy/client side, the error can be caught as a DBus::Error::pointer. The what() of the oritinal exception is then contained in the message() of the DBus::Error. -- Emmanuel Raulo-Kumagai ________________________________________ De : Robert Middleton [rmi...@sy...] Date d'envoi : mardi 8 octobre 2013 15:01 À : RAULO-KUMAGAI Emmanuel NRS Cc : dbu...@li... Objet : Re: [Dbus-cxx-users] Feature request with patch proposal: propagate exceptions through DBus You can attach patches here. I'll take a look at it, and see about putting it in. On a side note, I have been meaning to do exception handling for a while now, but I haven't gotten around to it. I know that dbus-java will catch all exceptions and then return an error message back onto the bus if an exception is caught or NULL is returned from a function. -Robert Middleton On Tue, Oct 8, 2013 at 5:24 AM, <emm...@or...<mailto:emm...@or...>> wrote: Hello, DBus provides the possibility for a method call to throw an error. However DBus-cxx in its current shape doesn't mirror this feature; message call handlers don't catch exceptions so, if an error condition arises in a slot bound to a DBus method, the exception is bubbled all the way up to the dispatcher and stops it. A possibility is of course to use return codes in APIs exposed over DBus rather than throw exceptions but that doesn't feel like the way of modern C++. My proposal would be to call the slot bound to a DBus method in a try block and catch std::exception&. In the case an exception occured, a DBus error message can be sent as a reply to the caller. I made a patch for that purpose, which I can provide. It might be a little quick & dirty though, as I had to change the signature of one of the DBus::ErrorMessage constructors (the one that constructs a reply) to accept a Message::const_pointer as first argument. I don't know if the mailing list is the right place to send the patch. Thanks in advance for your support. Regards, -- Emmanuel Raulo-Kumagai _________________________________________________________________________________________________________________________ Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration, Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci. This message and its attachments may contain confidential or privileged information that may be protected by law; they should not be distributed, used or copied without authorisation. If you have received this email in error, please notify the sender and delete this message and its attachments. As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified. Thank you. ------------------------------------------------------------------------------ October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk _______________________________________________ Dbus-cxx-users mailing list Dbu...@li...<mailto:Dbu...@li...> https://lists.sourceforge.net/lists/listinfo/dbus-cxx-users _________________________________________________________________________________________________________________________ Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration, Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci. This message and its attachments may contain confidential or privileged information that may be protected by law; they should not be distributed, used or copied without authorisation. If you have received this email in error, please notify the sender and delete this message and its attachments. As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified. Thank you. |