Handling of import errors
Description
̀̀PDI_import
can be used to expose buffer with access properties set to PDI_IN.
The question is how to handle import errors when:
- no import is performed (no plug-in or bad configuration)
- import has failed but the buffer is unchanged
- import has failed and the data is or may be corrupted (worst case)
- transactions prevent using the return status of import
Proposal
Composing with @jbigot and other ideas, we have:
- Setting and checking errors
- When sharing with the access property "PDI_IN", the latest content should be considered as invalid (Default). A flag could be added to the access properties for that for instance
PDI_NO_CONTENT
orPDI_UNDEFINED
. - The flag has to be removed by the plug-ins on success only or if the buffer content has been corrupted
PDI_UNAVAILABLE
orPDI_CORRUPTED
. To avoid developer from manipulating the data structure, aPDI_data_set_validity( PDI_data_t data, int is_available)
should be provided. - A function should be provided to test the data validity (useful if two plugins are coupled)
PDI_data_is_available( PDI_data_t data)
orint PDI_data_validity( PDI_data_t data)
- Handling errors
- A (global) default setting of PDI can be made available to stop the program after a transaction if the data are corrupted:
required_for_success:
transaction: init
- Plug-ins can provide their own mechanism during transaction
- Local to the plug-in
- Coupled with an other plug-in:
on_success
/on_failure:
"action to perform". This last point still need some reflection to be factorised for all plug-in.
Edited by Julien Bigot