unify error messages via templates #2697
At the moment very similar error/warnings have irrelevant differences or are missing important information (e.g. #2660).
I propose that we get templates (macros with predefined text) for some of the error categories. E.g. for validation errors, in nearly all cases, the error message template could look like:
Of course it would not work with every error message but it would be helpful in common cases.
It is a nice idea, but the use of this macro would be complicated. The
Also I think your template is to restrictive. Many validation plugins just have a condition that the value has to meet (reference to existing key, must be integer, match regex, etc.). Something like this may work better:
As said: not in every situation it is best to use the macro. If you have exactly these arguments, they will help. If one argument is missing, you will hopefully rewrite the code so that you deliver the needed information. (Which is the main purpose of these templates: to give a guideline which information should be present.)
We already have such macros, e.g. ELEKTRA_MALLOC_ERROR and ELEKTRA_SET_ERROR_READ_ONLY, see src/include/kdbmacros.h
My proposal here is to unify them and to match them with the categories we have.
We decided to drop the separation of "description" and "reason". Furthermore, "reason" would be typically constructed out of other parts.