Last modified: 2014-06-30 13:29:18 UTC
Wikibase API modules currently often provide a localized error info when calling ApiBase::dieUsage. This is inconsistent with current practice in core, and insufficient for providing localized errors in the UI. Instead, we should use a new call like dieUsageWithMessage, providing an error code an a Message objects (or message key and parameters). An unlocalized error info may be added, but seems redundant. This should work similarly to the error reports generated from Status objects, as introduced by I4094feee as a solution to bug 45099. Note that ApiBase::dieUsageMsg() is similar, but insufficient (as it doesn't provide message keys and parameters to the caller). Also, it requires us to define a mapping between error codes and messages, which is painful to maintain, and non-obvious to use.
After several discussions with Wikibase and MediaWiki core developers, it seems that for the use case of bots, unlocalized, hard coded error messages are preferred. However, when showing an error in the UI, we want a localized message. Suggestion: * For all errors arising from the client not conforming to the requirements of the API module (missing or malformed parameters, etc), use hard coded english messages. * For errors resulting from user input or system state (edit conflict, db is read only, etc), use a localized message. These will usually come from a Status object. ApiWikibase::handleStatus() implements this logic.
(In reply to comment #1) > * For errors resulting from user input or system state (edit conflict, db is > read only, etc), use a localized message. These will usually come from a > Status > object. ApiWikibase::handleStatus() implements this logic. So if a bot runs into an edit conflict it gets a message in some unexpected language, possibly full of HTML and local-wiki customizations?
Picking this up again after some time: Error reporting in Wikibase API modules needs to be rewritten. Here are some key points (not a full spec): * We need a helper class that for handling errors. * We want to be able to report errors by code, based on an Exception, and based on a Result object. * We want to stay compatible with the core APIs way of reporting errors (plain english message plus an error code). * In addition, we want to provide localized, HTML formatted messages where possible. * Error localization should be factored into appropriate components, for mapping codes resp. Exceptions to Message objects. * We want a way to provide "codes" for warnings too, e.g. for indicating a null-edit or a auto-resolved edit conflict or self-conflict.
Change 124323 merged by jenkins-bot: (bug 45277) Introducing ApiErrorReporter https://gerrit.wikimedia.org/r/124323