Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin API: *_plugin_get_last_exception: Return pointer to last exception #2052

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jrohel
Copy link
Contributor

@jrohel jrohel commented Feb 10, 2025

Closes: #2047

To prevent function names from being mangled in the plugin API, these functions are linked as C language functions (extern "C"). We do not throw exceptions from these functions. Specifically, the libdnf_plugin_new_instance and
dnf5_plugin_new_instance functions return a null pointer on failure and discard the exception. Thus, the caller (libdnf library or dnf5 application) does not know the reason for the failure.

Changes:

  • This modification extends the libdnf and dnf5 plugin APIs with new libdnf_plugin_get_last_exception and dnf5_plugin_get_last_exception functions. The plugin can save the exception instead of discarding it. The new functions allow access to the saved exception.

  • All plugins have been modified to implement the new API functionality.

  • Documentation string were improved.

Note:
The original functions are unchanged. Plugins that do not implement the new functions can still be used. API and ABI remain compatible.

…tion

To prevent function names from being mangled in the plugin API, these functions
are linked as C language functions (extern "C"). We do not throw exceptions from
these functions. Specifically, the `libdnf_plugin_new_instance` and
`dnf5_plugin_new_instance` functions return a null pointer on failure and
discard the exception. Thus, the caller (libdnf library or dnf5 application)
does not know the reason for the failure.

This modification extends the libdnf and dnf5 plugin library APIs with new
`libdnf_plugin_get_last_exception` and `dnf5_plugin_get_last_exception`
functions. The plugin can save the exception instead of discarding it. The new
functions then allow access to the saved exception.

Documentation string were improved.
Plugins no longer discard the exception generated in
the `libdnf_plugin_new_instance` and `dnf5_plugin_new_instance`
functions. The exception is saved.

Plugins implement the `libdnf_plugin_get_last_exception` or
`dnf5_plugin_get_last_exception` function to retrieve the saved
exception.
@jrohel jrohel force-pushed the plugin_get_last_exception branch 2 times, most recently from 672ea33 to 071cd7e Compare February 11, 2025 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The plugins libdnf_plugin_new_instance and dnf5_plugin_new_instance API functions discard exceptions
1 participant