The APiErrorReporter provides unified formatting and localization for all API errors, but is so far not used in all modules / for all cases. The WikibaseApi base class provides convenience functions that delegate to an APiErrorReporter, so replacing the old dieUsage calls should be as easy as:
- dieStatus if you have a Status object
- dieException if you have an Exception
- dieError otherwise (this has the same signature as dieUsage, but applies localization if possible).
All of these take API error codes; they will be passed on to dieUsage as before, but in addition, are used to find an appropriate system message for a localized error message. The message key is constructed as 'wikibase-api-' . $errorCode. If you use the new functions, please also provide the appropriate system messages.
Note that dieException uses an ExceptionLocalizer which may provide a more detailed error message, and die Status will take messages from the Status object, if there are any, so the message based on the error code may not always be used (this may be changed to just combine all the messages, instead of having the override each other).
Version: unspecified
Severity: normal
Whiteboard: u=dev c=backend p=0
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=67732