Page MenuHomePhabricator

Use ApiErrorReporter for all API errors.
Closed, ResolvedPublic

Description

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

Details

Reference
bz64874

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 3:16 AM
bzimport set Reference to bz64874.
bzimport added a subscriber: Unknown Object (MLST).

marius, can you look into that?

Change 148622 had a related patch set uploaded by Hoo man:
Made all API modules use ApiErrorReporter

https://gerrit.wikimedia.org/r/148622

Change 148622 merged by jenkins-bot:
Made all API modules use ApiErrorReporter

https://gerrit.wikimedia.org/r/148622