Error management in grl-plugin-registry APIs
- From: Iago Toral Quiroga <itoral igalia com>
- To: grilo-list gnome org
- Subject: Error management in grl-plugin-registry APIs
- Date: Fri, 17 Dec 2010 14:21:54 +0100
Hi,
recently we decided to add API to allow loading plugin configuration
from a key-file (check out bug 636064 for details), and in the process
we realized it would make sense to add a GError parameter to that API
and, for coherence, also to some other functions in grl-plugin-registry
that can raise error conditions that, at the moment, are handled with a
gboolean return parameter with no additional error description.
I see three situations:
a) Functions that can fail for more than one reason. In this case a
GError parameter seems necessary.
b) Functions that can fail for only one known reason. In this case a
gboolean return is enough, but adding the GError parameter would maybe
add some coherence to the API.
c) Functions that cannot fail now, but we suspect in the future could
do more work and could raise errors. In this case we can wait till that
happens and change the API or we can prepare for that now already and
avoid API changes in the future.
Following are the APIs that deal with error conditions or return
gboolean at the moment:
1) grl_plugin_registry_register_source
-> No error conditions, it always reuturns TRUE
-> Basically, it just adds the source to a hash table.
I think this is case c), and I would be more for adding the GError
parameter to the API now.
2) grl_plugin_registry_unregister_source
-> Source not found
This is case b) now, could be a) in the future maybe. I say we add a
GError.
3) grl_plugin_registry_load
-> Failed to open
-> invalid plugin descriptor
-> Failed to init plugin
This is a), I would add a GError.
4) grl_plugin_registry_load_directory
-> Failed to open
-> For each specific plugin file, the errors above
-> We could probably raise an error if any of the plugins failed to
load
This is a). I would add the GError.
5) grl_plugin_registry_load_all
-> We could get errors for individual dirs
-> We could probably raise an error if any of the directories failed
This is b) at least or a) depending on your POV. I would add the GError.
6) grl_plugin_registry_unload
-> Plugin not found
-> For each source in the plugin
-> nuregister_source could fail
-> plugin_deinit could fail
This is a). I would add the GError.
7) grl_plugin_registry_register_metadata_key
-> Key already exists
This is b), does not look like something that could become a) and the
only reason for failure is obvious. I would not add the GError here, but
don't have a strong opinion at all.
8) grl_plugin_registry_add_config
-> plugin does not exist
This is b), could be a) in the future. I would add the GError.
Opinions?
Iago
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]