On 1/4/08, Roan Kattouw roan.kattouw@home.nl wrote:
There's the problem: I can't just go ahead and tell the user the request failed, I'd also like to tell them *why*. A simple return null isn't very useful. Also note that UserrightsPage's function for this task (saveUserGroups) doesn't return anything: it can't fail except through some fatal DB error or other disaster, in which case it'll never return anyway. Now I could go ahead and introduce more return value constants for bad tokens, or I could just check the token in ApiChangeRights, which is much simpler.
Duplicating logic is less robust, and leads to more bugs. The correct way to do it, which I believe is used elsewhere in the core code now to support the API, is to have error return codes of some kind, not to just check for all the errors in the display logic.