openbmc / sdbusplus

C++ bindings for systemd dbus APIs
Apache License 2.0
104 stars 82 forks source link

exceptions: ensure method call exception types are different between internal dbus failures and call returns #54

Closed williamspatrick closed 1 year ago

williamspatrick commented 3 years ago

Right now method call exceptions turn into a generic sdbusplus internal_exception even though they are not internal. Switch up the class hierarchy and provide some handling so that org.freedesktop.dbus exceptions become internal exceptions and other types become non-internal.

frsauvage commented 1 year ago

Hi, is there any workaround ? I have the same requirement, Regards, Francine

williamspatrick commented 1 year ago

I think what I intended to do here is mostly done. There is now exception, generated_exception, internal_exception and a number of sub-classes of these.

Can you elaborate on what your requirement is if it isn't already met?

frsauvage commented 1 year ago

Hi @williamspatrick ,

Thank you to help me, I am grateful !

I agree with you, it is working on dbus . But I can't figure out how to code it with async_method_call.

I simply throw an exception in my dbus service : image

And I receive it on client side.

My service works with a pure dbus call: image

But with bmcweb, client side with an async_call_method, I recevie the error as a boost::system::error_code:

image

image

I cannot figure out what I should code ? Should I use another async_method_call ? a one without boost::system::error_code ? Should I cast my boost error_code (to what?) ?

How can I compare my thrown exception (inheriting sdbusplus::exception_t) with the received exception inasync callback ec (typed as boost::system::error_code) ?

I found a generated map_exception I tried to display message, value properties: wierd : category name is generic and value is 5.

I should have missed smth obvious, according to your anwser, it is sometimes difficult to imagine what is generated for our convenient :-).

What do you mean by internal_exceptionand generated_exception? I may have an old sdbusplus version, it could explain why I do not understand....

PS: Sorry for my english, I am French, tell me if you don't understand my explanation, Best Regards, Francine

frsauvage commented 1 year ago

@williamspatrick I understood what you said. I patch with https://gerrit.openbmc.org/c/openbmc/sdbusplus/+/21611/1/sdbusplus/asio/detail/async_send_handler.hpp#116

Thanks,